Dear all,
Great thanks to Gabriel, Wayne, and Michael on their insightful comments. The use of changeValues (v1, v2, v3) is exactly what I want. I feel so sorry that I did not notice this macro function before. I think it is important to know what "The image may not be displayed correctly because the Image>Adjust>Threshold command uses a 256 entry LUT but you can write a macro that sets the threshold range to 1-5000 and converts the image to binary" from Wayne's and Michael' s comment. We should put this important information in the ImageJ user Guide. We can continue to use "setThreshold" and "Create Mask" to get the right image even the display is not correct. Cheers! Zhengyu -----Original Message----- From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Michael Schmid Sent: Tuesday, October 21, 2014 12:03 PM To: [hidden email] Subject: Re: Can not set Threshold at 1 Hi Zhengyu, one more remark: Even if you don't see the correct pixels painted red, most operations using the threshold do the correct thing. So if you have a 16-bit image and set the Threshold at from 1 to 1, operations like 'Create Mask' or the Wand tool select the area where the pixel value is exactly one. (for the Wand tool, of course you have to know where to click, which might be a problem is you don't see it). What exactly do you have in mind? Seeing where a given cell number can be found in something like the 'Count Masks' created by Analyze Particles? If you use Analyze Particles with "record starts" enabled, one could e.g. create a macro that recovers the starting coordinates of a given particle, uses the Wand to select it, and then use Overlay.addSelection("", 0, "red") to show it red. Michael ________________________________________________________________ Dear ImageJ colleagues, > > I have a 16-bit image with labeled cells. Pixel values for cell 1 is 1, and pixel values for cell 2 is 2, and so on. The background pixel value is zero. There are about 5000 cells in this image. When I tried to make a binary image to mask all cells using thresholding ( set threshold at 1). Surprisingly, the whole image becomes red (I set the threshold mode as RED), and I found that the minimum threshold I could use is 16. I would like to use setThreshold( 1, 5000), but it does not seem to do in that way. Please make a sample image available online. It is difficult to answer a question like this without having an image to use for testing. The image may not be displayed correctly because the Image>Adjust>Threshold command uses a 256 entry LUT but you can write a macro that sets the threshold range to 1-5000 and converts the image to binary. The following example macro opens the Particles sample image, converts the 5097 particles to count masks (first particle has pixel values of 1, second has pixel values of 2, etc.), sets the threshold to 1-5000 and converts to binary. The resulting binary image has 5000 particles. -wayne setBatchMode(true); run("Particles (75K)"); setAutoThreshold("Default"); run("Analyze Particles...", " show=[Count Masks]"); setThreshold(1, 5000); setOption("BlackBackground", true); run("Convert to Mask"); setBatchMode(false); > Is there any people could help me to explain why this happens, and how to set the threshold at 1? Should I use plugin to do it? I am currently using ImageJ 1.47 and I found FIJI has the same issue too. > > Thanks! > > Zhengyu -----Original Message----- From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Gabriel Landini Sent: Tuesday, October 21, 2014 9:13 AM To: [hidden email] Subject: Re: Can not set Threshold at 1 On Tuesday 21 Oct 2014 12:56:47 you wrote: > I have a 16-bit image with labeled cells. Pixel values for cell 1 is > 1, and pixel values for cell 2 is 2, and so on. The background pixel > value is zero. There are about 5000 cells in this image. When I tried > to make a binary image to mask all cells using thresholding ( set threshold at 1). > Surprisingly, the whole image becomes red (I set the threshold mode as > RED), and I found that the minimum threshold I could use is 16. I > would like to use setThreshold( 1, 5000), but it does not seem to do in that way. > > Is there any people could help me to explain why this happens, and how > to set the threshold at 1? Should I use plugin to do it? I am > currently using ImageJ 1.47 and I found FIJI has the same issue too. This is because the thresholder uses a 256-bin histogram out of the 16 bit image to pack it into a manageable size, so in the first bin there are more than one pixel value. You perhaps need to do it by hand: go pixel by pixel and set it to the highest value and the rest to 0. Or use the changeValues(v1, v2, v3) macro function. Hope this helps Gabriel -- 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 |