Pixel grey scale value per ROI

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

Pixel grey scale value per ROI

AJBell
Dear All,

I am trying to find a way to list all pixel values for a given ROI. Having
searched the archive, I found a code that gives the pixel values for a
predetermined roi.

getSelectionBounds(xmin, ymin, selwidth, selheight);
run("Create Mask");
m=newArray(w*h);
for(x=0;x<w;x++){
       for(y=0;y<h;y++){
               m[y*w+x]=getPixel(x,y);
       }
}
close(); //close mask
for(x=xmin;(x<=xmin+selwidth);x++){
       for(y=ymin;(y<=ymin+selheight);y++){
               if (m[y*w+x]!=0) print (x,y,getPixel(x,y));
       }
}

What I have are images with up to 50 bacterial cells, and having
thresholded the image, I would like a list of the pixel values for each
ROI. I know in principle how to do this for a single ROI in turn, but with
approx 1200 cells that would take a long time. Is there a way to do this?
Or will I have to do it by hand as it were?

Regards,

Andrew
Reply | Threaded
Open this post in threaded view
|

Re: Pixel grey scale value per ROI

Michael Schmid
Hi Andrew,

two options:

(1) If you don't care about the sequence, simply remove the first  
line from your macro and run it with the thresholded image.

(2) If you want the particles (bacteria) in the proper sequence, use  
'add to roi manager' on the particle analyzer and loop over the rois.

Michael
________________________________________________________________

On 17 Sep 2009, at 11:03, Andrew Bell wrote:

> Dear All,
>
> I am trying to find a way to list all pixel values for a given ROI.  
> Having
> searched the archive, I found a code that gives the pixel values for a
> predetermined roi.
>
> getSelectionBounds(xmin, ymin, selwidth, selheight);
> run("Create Mask");
> m=newArray(w*h);
> for(x=0;x<w;x++){
>        for(y=0;y<h;y++){
>                m[y*w+x]=getPixel(x,y);
>        }
> }
> close(); //close mask
> for(x=xmin;(x<=xmin+selwidth);x++){
>        for(y=ymin;(y<=ymin+selheight);y++){
>                if (m[y*w+x]!=0) print (x,y,getPixel(x,y));
>        }
> }
>
> What I have are images with up to 50 bacterial cells, and having
> thresholded the image, I would like a list of the pixel values for  
> each
> ROI. I know in principle how to do this for a single ROI in turn,  
> but with
> approx 1200 cells that would take a long time. Is there a way to do  
> this?
> Or will I have to do it by hand as it were?
>
> Regards,
>
> Andrew