Binarize an image to 0 and 1s (not 0 and 255)


I realise this is a very basic question. I have genuinely combed through the docs and i cant see any way to do this. I have an RGB image that i have created masks for - when i create the mask the pixels are flipped into 0 and 255. I’m trying to find a way to make them 0 and 1. It would be great if someone could give some feedback here - i realise this is simple, i could write some python script however i’m trying to find a way to do this in a self contained manner for another user.


Hi @roryw10,

One option: you would still initially be getting your 8-bit binary but then you can run the two commands below to set all the 255 values to 1.

run("Create Selection");
run("Set...", "value=1");

super helpful, thankyou @lmurphy !!! I will have a look for how to do this in a batch as there will be several hundred images i need to generate masks for!

And another option would be Process-Math-Divide:
run("Divide...", "value=255");
0/255 = 0
255/255 = 1
Just for fun :slight_smile:


Yes, that’s much better!

1 Like