Dear ImageJ Community,
I am trying to use ImageJ to describe surface texture, which can be reduced to a distribution of pixel values. Is there a function summarizing the pixel distribution within an area of interest? For example, if all the pixels are either black or white (i.e. pixel values are binary), can I query ImageJ to discover a) how many pixels are in the area of interest and b) how many are black? I greatly appreciate any thoughts/comments/suggestions! Many thanks, Glenn Matlack -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Good day Glenn,
what about looking at the histogram of the ROI? Best :::::::::::::::::::::::::::::::::::::::: On 03.02.15 17:14, Matlack, Glenn wrote: > Dear ImageJ Community, > > I am trying to use ImageJ to describe surface texture, which can be > reduced to a distribution of pixel values. Is there a function > summarizing the pixel distribution within an area of interest? For > example, if all the pixels are either black or white (i.e. pixel > values are binary), can I query ImageJ to discover a) how many pixels > are in the area of interest and b) how many are black? I greatly > appreciate any thoughts/comments/suggestions! > > Many thanks, Glenn Matlack > > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Matlack, Glenn
Here's a macro to count up dark (=0) and white (=255) pixels in a rectangular selection:
getSelectionBounds(x,y,width,height); yend = y+height; xend = x+width; WhiteCount=0; DarkCount=0; for(j=y;j<yend;j++){ for(i=x;i<xend;i++){ I = getPixel(i,j); if(I == 0){ DarkCount=DarkCount+1; }else{ WhiteCount=WhiteCount+1; } } } print("Dark White"); print(d2s(DarkCount,0)+" "+d2s(WhiteCount,0)); |
Also...
// Assumes images are 8 bit; no error checking for this. function methodByHistogram() { getHistogram(values, counts, 256); print("Black \t White"); print(counts[0]+" \t "+counts[255]); } ========================================================================= Michael Cammer, Microscopy Core & Skirball Institute, NYU Langone Medical Center Cell: 914-309-3270 Temporary location: SK2-7 http://ocs.med.nyu.edu/microscopy & http://microscopynotes.com/ -----Original Message----- From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of mattjackson Sent: Tuesday, February 03, 2015 12:23 PM To: [hidden email] Subject: Re: Pixel summary data? Here's a macro to count up dark (=0) and white (=255) pixels in a rectangular selection: getSelectionBounds(x,y,width,height); yend = y+height; xend = x+width; WhiteCount=0; DarkCount=0; for(j=y;j<yend;j++){ for(i=x;i<xend;i++){ I = getPixel(i,j); if(I == 0){ DarkCount=DarkCount+1; }else{ WhiteCount=WhiteCount+1; } } } print("Dark White"); print(d2s(DarkCount,0)+" "+d2s(WhiteCount,0)); -- View this message in context: http://imagej.1557.x6.nabble.com/Pixel-summary-data-tp5011424p5011428.html Sent from the ImageJ mailing list archive at Nabble.com. -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Good call, Michael. I learned to program in Fortran 77, so I tend to program strings like that instead of looking for built in functions. Still trying to break that habit.
|
Matthew and Michael,
Many thanks - that looks very helpful! Best, Glenn -----Original Message----- From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of mattjackson Sent: Tuesday, February 03, 2015 1:20 PM To: [hidden email] Subject: Re: Pixel summary data? Good call, Michael. I learned to program in Fortran 77, so I tend to program strings like that instead of looking for built in functions. Still trying to break that habit. -- View this message in context: http://imagej.1557.x6.nabble.com/Pixel-summary-data-tp5011424p5011430.html Sent from the ImageJ mailing list archive at Nabble.com. -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |