Re: setting auto threshold in a macro
Posted by
Rasband, Wayne (NIH/NIMH) [E] on
Jul 29, 2010; 6:20pm
URL: http://imagej.273.s1.nabble.com/setting-auto-threshold-in-a-macro-tp3687423p3687424.html
On Jul 29, 2010, at 1:44 PM, Crowell Elizabeth wrote:
> Hello group members,
>
> I have yet another question for you.
> I am trying to write a macro (attached) that will select particles of a
> defined size in my images (in this case, nuclei). I make a projection
> of my stack, try to auto threshold it with a dark background, make it
> binary, and run analyze particles.
>
> When I adjust the threshold manually, clicking the auto button with the
> "dark background" box checked gives me exactly the result desired.
> Therefore I think my images are of sufficient quality to let me
> threshold them automatically.
>
> However, the auto threshold function is not functioning properly in the
> macro. The thresholding is not restrictive enough (it takes a wide
> spectrum of gray values around the particles that just represent
> noise). When I put in a wait function and run the macro while batchmode
> = false, I can see that in the threshold window, the "dark background"
> box is never checked. If I run the macro with the waitForUser line, the
> image is thresholded correctly initially, and then changes to an
> incorrect, non-restrictive threshold when the dialog box appears. So
> there is something really fishy going on!
>
> How can I instruct ImageJ to adjust the threshold automatically with a
> dark background? Apparently, the line "setAutoThreshold("Default
> dark");" is not sufficient.
>
> Thank you in advance for your help,
What version of ImageJ are you using? There are two recent setAutoThreshold() bug fixes listed in the release notes (
http://rsbweb.nih.gov/ij/notes.html).
v1.44c:
Fixed a bug in the setAutoThreshold() macro function that caused the threshold level to be one less than the level set by the "Threshold" widget when "Dark background" was enabled.
v1.43u:
Fixed a bug that caused the setAutoThreshold() macro function to not work correctly with 16 and 32 bit images that were not using the default display range.
-wayne