On Nov 23, 2012, at 4:52 PM, cmcwell wrote:
> Sorry if this has been answered before. I am trying to get a count of
> pixels containing only red values (1,0,0; 2,0,0; 3,0,0; etc.). I guess
> what I need, then, is a list of pixel values with all three colors
> listed, so I can choose the totals for the red-only pixels. Is this
> possible? Thanks.
If you need the individual counts of each red level, you could
Set foreground to 255, and background to 0.
Separate the rgb image into 3 8 bit images.
Threshold (make binary) the green plane at 0:0 and the blue plane at 0:0 (so
the thresolded part is 255 and the rest 0).
Combine those two images using the AND operator. (so the result is 255 where
green and blue are 0).
Then AND the result with the red plane. (so only remain the red pixels which
are non-0 andn green 0 and blue 0)
The histogram of that result should show the number of pixels with 1,0,0,
2,0,0, etc. (except for 0,0,0, but if you need it you can always search those
with the loop Wayne posted earlier).
Press the list button in the histogram window and you see the counts.
Mind the line breaks!
//------------8<-----------------
setForegroundColor(255,255,255);
setBackgroundColor(0,0,0);
run("Clown (14K)");
run("Split Channels");
selectWindow("clown.jpg (green)");
setThreshold(0, 0);
run("Convert to Mask");
selectWindow("clown.jpg (blue)");
setThreshold(0, 0);
run("Convert to Mask");
imageCalculator("AND create",
"clown.jpg (green)","clown.jpg (blue)");
imageCalculator("AND create",
"Result of clown.jpg (green)","clown.jpg (red)");
selectWindow("Result of Result of clown.jpg (green)");
run("Histogram");
//------------8<-----------------
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html