Invert a selection in a binary image / select background only

Dear ImageJ users,

I created a binary image and select all “black pixels” by Edit -> Create Selection.
However I want also to select the exact inverse of that.

I tried to use Edit -> Invert and then Edit -> Create Selection.
However this then selects the (now) white pixels which is the same as before.

In other words, I want to select the whole background of the binary image.

Any suggestions how to do this?
I certainly could write a for loop and check if my pixel is background
and then use MakePoint to select all points, but I’m sure this is not the best way to do it.

Best wishes,

Hi @stephanmg ,

Try >Edit >Selection >Make inverse

1 Like

Hey @biovoxxel I tried this, but this does not select the inverse.

Hello again!

I agree with @biovoxxel that the “Make Inverse” command should work.

For example, if you run the macro below, you should get 2 results. The first result is the original selection, with a mean of 255. The second result is the inverse, with a mean of 0.

If this sample works but your code doesn’t work, it would be helpful to see your code.

Hope it helps.

run("Dot Blot (7K)");
run("Make Binary");
run("Create Selection");
run("Set Measurements...", "mean display redirect=None decimal=2");
run("Make Inverse");

You are right,
it works!

It was an error at another position in the macro (after the selection was transferred to another image).
I used the wrong Edit command (confused Clear vs. Clear Outside).