How to threshold image that has been clear outsided when pixels with 0 value are of interest

Hi
after performing Clear Outside with ROIs on an image Stack everything outside Rois became BLACK (0 value)

Though inside ROIS there are also pixels with O value (black) that I am interested on …

So when thresholding the Stack, if i try to include them … all the "background " is also selected …

any ideas how to overcome such problem?

I don’t know how much variability is in your images, but the simplest (based on that one image) would be to put a size threshold on your Analyze Particles that eliminates areas above the size that you could possibly be interested in.

It wouldn’t have any knowledge of inside or outside, but it would work for similar images. If you have places where your foreground pixels chop up the outer area, though, that will fail. You might want to look into replacing the outer pixels with something other than 0, or doing image math where you add 1 to the entire image prior to clearing the outside. For the latter, your pixels of interest would now be 1, rather than 0.

1 Like

I can think of many ways to deal with the ROIs in downstream processing, but I will focus on the immediate issue at hand. Try Using “Process > Math > Add…” to add a value, say 1, to all the pixels before using Clear Outside.

1 Like

@markkitt & @Research_Associate thanks alot for the tip

I realized myself yesterday night, that I should act BEFORE clear outside command… I ll try your aproach …I think it would be very interesting ImageJ developers to add on CLEAR OUTSIDE command the option that will let user choose if he wants the “outside” to get a particular pixel value (0-255 etc) or even Black & white option …

Just so you know this kind of is possible as “Clear Outside” will set outside to whatever colour is currently set as “Background”. This is usually black. You can go to Edit > Options > Colors to set it to another colour.

If you want to set something outside of the name options in that menu then you can use the colour dropper to set RGB values for foreground and background (by clicking on the F and B boxes respectively). Setting a value like this would be a little odd though. Say you wanted the value to be 75, you would set each R,G, and B to 180 (255-75).

image

But to be honest, the way I would do it in practise would not be either of those options, I would make an inverse of the ROI using Edit > Selection > Make Inverse and then use Process > Math > Set to set the value of all the pixels outside the ROI to a specific value.

2 Likes