Re: Thresholding an image

Posted by Wayne Rasband-2 on
URL: http://imagej.273.s1.nabble.com/Thresholding-an-image-tp5019043p5019045.html

> On Jul 7, 2017, at 5:03 PM, Yevgeniy Romin <[hidden email]> wrote:
>
> Hello everybody
>
> I found something peculiar and was wondering whether this is a bug.  If I threshold an image and hit apply, it usually generates a binary mask of the thresholded region.  If I do the same thing after running the "tubeness" algorithm on the image, a prompt pops up that asks whether I want to set the background pixels as NaN.  If I say yes, it keeps the image as is without the non-thresholded pixels, and if I say cancel, it generates the standard binary mask.  After looking around a bit, it seems that the set background pixels as NaN option only works on 32-bit floating images (very specific).  I found this option to be very useful, is there any way to have it or something similar (like setting background pixes to 0) when thresholding regular images?  Because it's very convenient, at least for what I am doing.

You can do this using a simple macro. For example, this one thresholds the 8-bit AuPbSn sample image and sets the background to zero.

   run("AuPbSn 40 (56K)");
   setAutoThreshold("Default");
   getThreshold(t0, t1);
   changeValues(0, t0-1, 0);
   changeValues(t1+1, 255, 0);
   resetThreshold();

-wayne

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