counting pixels

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

counting pixels

Annapragada, Sriram K.
I am new to Image J and had the following questions. Any help will be really appreciated
 
1) How do we count number of pixels of a certain value in a series of images in a stack (it works for a single image; I am unable to set up a for loop for the series of images in a stack).
 
2) Once I get the pixel count, is there way to transfer the data to an excel file or text file?
 
thanks,
Kiran.

________________________________

From: ImageJ Interest Group on behalf of Rasband Wayne
Sent: Sat 1/28/2006 9:41 PM
To: [hidden email]
Subject: Re: ImageJ as an applet and plugin support



> Any way to set or change the memory for an Applet?

You set the applet memory limit by entering something like

      -Xmx500m
in the Java Plug-in's "Java Runtime Parameters" field. On Mac OS X,
the Java Plugin (there is one for each version of Java) is in
Applications/Utilities. On Windows, it is a Control Panel. With the
signed version of the ImageJ applet now available at <http://
rsb.info.nih.gov/ij/signed-applet/>, you can also use the File>Open
and File>Save As commands.

-wayne
Reply | Threaded
Open this post in threaded view
|

Re: counting pixels

Michael Doube-2
Hi Kiran.  In the macro language, you can do this:
--------------
var n;
var row;

macro "Count Grey Pixels [b]" {

//Make a dialog box
Dialog.create("Enter a grey level");
Dialog.addNumber("Grey level", 0);
Dialog.show();
n = Dialog.getNumber();

//Count the pixels of grey value n in each slice
for (i=1; i<=nSlices; i++) {
        setSlice(i);
        getRawStatistics(count, mean, min, max, std, histogram);
        pixelcount=histogram[n];     //n is the grey value you want to count
        pixelcount=pixelcount+pixelcount; //does a cumulative sum for
each iteration of the loop      
}
setResult("Count", row, pixelcount);
updateResults();
row++;      
}
-----------------------------------
I borrowed most of this code from stuff I've written before.
Install it and it will run when you hit [b].
Check out other macros and the macro function page
http://rsb.info.nih.gov/ij/developer/macro/functions.html for more ideas.

Cheers

Mike

Annapragada, Sriram K. wrote:

> I am new to Image J and had the following questions. Any help will be really appreciated
>  
> 1) How do we count number of pixels of a certain value in a series of images in a stack (it works for a single image; I am unable to set up a for loop for the series of images in a stack).
>  
> 2) Once I get the pixel count, is there way to transfer the data to an excel file or text file?
>  
> thanks,
> Kiran.
>
> ________________________________
>
> From: ImageJ Interest Group on behalf of Rasband Wayne
> Sent: Sat 1/28/2006 9:41 PM
> To: [hidden email]
> Subject: Re: ImageJ as an applet and plugin support
>
>
>
>  
>> Any way to set or change the memory for an Applet?
>>    
>
> You set the applet memory limit by entering something like
>
>       -Xmx500m
> in the Java Plug-in's "Java Runtime Parameters" field. On Mac OS X,
> the Java Plugin (there is one for each version of Java) is in
> Applications/Utilities. On Windows, it is a Control Panel. With the
> signed version of the ImageJ applet now available at <http://
> rsb.info.nih.gov/ij/signed-applet/>, you can also use the File>Open
> and File>Save As commands.
>
> -wayne
>  

--
Michael Doube  BPhil BVSc MRCVS
MPhil / PhD Student
Dental Institute
Barts and The London School of Medicine and Dentistry
Queen Mary, University of London
New Rd
London  E1 1BB
United Kingdom

Phone +44 (0)20 7377 7000 ext 2681
Reply | Threaded
Open this post in threaded view
|

Re: counting pixels

Annapragada, Sriram K.
In reply to this post by Annapragada, Sriram K.
Thanks Mike, It works fine.
 
Kiran.

________________________________

From: ImageJ Interest Group on behalf of Michael Doube
Sent: Sun 1/29/2006 4:55 PM
To: [hidden email]
Subject: Re: counting pixels



Hi Kiran.  In the macro language, you can do this:
--------------
var n;
var row;

macro "Count Grey Pixels [b]" {

//Make a dialog box
Dialog.create("Enter a grey level");
Dialog.addNumber("Grey level", 0);
Dialog.show();
n = Dialog.getNumber();

//Count the pixels of grey value n in each slice
for (i=1; i<=nSlices; i++) {
        setSlice(i);
        getRawStatistics(count, mean, min, max, std, histogram);
        pixelcount=histogram[n];     //n is the grey value you want to count
        pixelcount=pixelcount+pixelcount; //does a cumulative sum for
each iteration of the loop    
}
setResult("Count", row, pixelcount);
updateResults();
row++;      
}
-----------------------------------
I borrowed most of this code from stuff I've written before.
Install it and it will run when you hit [b].
Check out other macros and the macro function page
http://rsb.info.nih.gov/ij/developer/macro/functions.html for more ideas.

Cheers

Mike

Annapragada, Sriram K. wrote:

> I am new to Image J and had the following questions. Any help will be really appreciated
>
> 1) How do we count number of pixels of a certain value in a series of images in a stack (it works for a single image; I am unable to set up a for loop for the series of images in a stack).
>
> 2) Once I get the pixel count, is there way to transfer the data to an excel file or text file?
>
> thanks,
> Kiran.
>
> ________________________________
>
> From: ImageJ Interest Group on behalf of Rasband Wayne
> Sent: Sat 1/28/2006 9:41 PM
> To: [hidden email]
> Subject: Re: ImageJ as an applet and plugin support
>
>
>
>  
>> Any way to set or change the memory for an Applet?
>>    
>
> You set the applet memory limit by entering something like
>
>       -Xmx500m
> in the Java Plug-in's "Java Runtime Parameters" field. On Mac OS X,
> the Java Plugin (there is one for each version of Java) is in
> Applications/Utilities. On Windows, it is a Control Panel. With the
> signed version of the ImageJ applet now available at <http://
> rsb.info.nih.gov/ij/signed-applet/>, you can also use the File>Open
> and File>Save As commands.
>
> -wayne
>  

--
Michael Doube  BPhil BVSc MRCVS
MPhil / PhD Student
Dental Institute
Barts and The London School of Medicine and Dentistry
Queen Mary, University of London
New Rd
London  E1 1BB
United Kingdom

Phone +44 (0)20 7377 7000 ext 2681