Count negative pixels in a stack

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Count negative pixels in a stack

sreeyuth
Hi,

I have around 440 images in my stack. From each image, I want to get the total number of pixels having negative values. So in the end I expect a list which has just 2 columns, Slice Number and No. of pixels having negative values in that slice.

Can someone please help me get this?

Best regards,
Lal.
Reply | Threaded
Open this post in threaded view
|

Re: Count negative pixels in a stack

Rasband, Wayne (NIH/NIMH) [E]
On Aug 16, 2013, at 10:48 AM, sreeyuth wrote:

> Hi,
>
> I have around 440 images in my stack. From each image, I want to get the
> total number of pixels having negative values. So in the end I expect a list
> which has just 2 columns, Slice Number and No. of pixels having negative
> values in that slice.

Here is a macro that does this:

saveSettings;
run("Clear Results");
run("Set Scale...", "distance=0 known=0");
setThreshold(-99999, -0.00001);
run("Set Measurements...", "area limit");
for (n=1; n<=nSlices; n++) {
   setSlice(n);
   run("Measure");
}
restoreSettings;

-wayne

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Count negative pixels in a stack

sreeyuth
Hi Wayne,

Thank you for this macro. It worked to the T!