Login  Register

Re: Make binary with manual threshold

Posted by Rasband, Wayne (NIH/NIMH) [E] on Oct 29, 2014; 7:07pm
URL: http://imagej.273.s1.nabble.com/Make-binary-with-manual-threshold-tp5010188p5010229.html

> On Oct 24, 2014, at 1:07 PM, Glen MacDonald <[hidden email]> wrote:
>
> There seems to have been a change in behavior with Fiji for creating a binary image through a macro.
>
> this worked 2 years ago :
> setThreshold(mn,255);
> run("Make Binary", "black”);
> but now it only sets the threshold without the red overlay or creating a binary image.

This works in the latest ImageJ daily build ( (1.49k2), except that the “black” option is ignored. Macros should explicitly set the “Black background” flag, as in this example:

   run("Dot Blot (7K)");
   setOption("BlackBackground", true);
   run("Make Binary");

> I need to set a stack to binary using a computed threshold, not with any of the automatic threshold routines.  
> thanks,

You can do this in the daily build. Here is an example:

   run("Fly Brain (1MB)");
   run("8-bit");
   setOption("BlackBackground", true);
   for (i=nSlices; i>0; i--) {
      setSlice(i);
      getRawStatistics(n, mean);
      setThreshold(mean, 255);
      //print(i, mean);
      run("Make Binary", "slice");
   }

-wayne

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html