binary image inversion irritation

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

binary image inversion irritation

Rainer M. Engel
Dear all,

I have to convert my 8bit images to binary images, containing only black
and white (0 & 255) pixels. That is OK and offers a wide range of
processing possibilities.

Imagine I have these two images (both are binary)
https://dl.dropboxusercontent.com/u/414433/imagej/bitbin/09.png
https://dl.dropboxusercontent.com/u/414433/imagej/bitbin/12.png

I didn't forget the settings..
//important values to set
run("Colors...", "foreground=white background=black selection=yellow");
run("Options...", "iterations=1 black edm=Overwrite count=1");

But image 12.png is inverted if I make it binary again. This happens
even if I blur it before that. I understand that Making Binary is some
sort of threshold process, which may in some situation swap or invert my
image.

Is there a way to make an image binary with an expression or formula,
all pixels darker 128 become 0, brighter ones become white?

Best Regards,
Rainer


--
Rainer M. Engel, Dipl. Digital Artist
scientific|Media GbR
Pichelsdorfer Str. 143
13595 Berlin

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: binary image inversion irritation

ctrueden
Hi Rainer,

> Is there a way to make an image binary with an expression or formula,
> all pixels darker 128 become 0, brighter ones become white?

If you have an active threshold set, the "Make Binary" command will respect
it when converting to a binary image. So in a macro, you can do something
like:

IJ.setThreshold(imp, 85, 170);
IJ.run(imp, "Make Binary", "thresholded remaining black");
// be careful whether your data has a black background or a white one,
though.

You can also have total control over the binarization using a custom macro.
Run Process > Math > Macro and try e.g.:

if (v<=104) v=0; else v=255

HTH,
Curtis


On Mon, Sep 9, 2013 at 9:11 AM, Rainer M. Engel <[hidden email]> wrote:

> Dear all,
>
> I have to convert my 8bit images to binary images, containing only black
> and white (0 & 255) pixels. That is OK and offers a wide range of
> processing possibilities.
>
> Imagine I have these two images (both are binary)
> https://dl.dropboxusercontent.com/u/414433/imagej/bitbin/09.png
> https://dl.dropboxusercontent.com/u/414433/imagej/bitbin/12.png
>
> I didn't forget the settings..
> //important values to set
> run("Colors...", "foreground=white background=black selection=yellow");
> run("Options...", "iterations=1 black edm=Overwrite count=1");
>
> But image 12.png is inverted if I make it binary again. This happens
> even if I blur it before that. I understand that Making Binary is some
> sort of threshold process, which may in some situation swap or invert my
> image.
>
> Is there a way to make an image binary with an expression or formula,
> all pixels darker 128 become 0, brighter ones become white?
>
> Best Regards,
> Rainer
>
>
> --
> Rainer M. Engel, Dipl. Digital Artist
> scientific|Media GbR
> Pichelsdorfer Str. 143
> 13595 Berlin
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: binary image inversion irritation

Rainer M. Engel
Hey Curtis,

that sounds great. Thank you for your help..

best regards,
Rainer

Am 09.09.2013 17:57, schrieb Curtis Rueden:

> Hi Rainer,
>
>> Is there a way to make an image binary with an expression or formula,
>> all pixels darker 128 become 0, brighter ones become white?
>
> If you have an active threshold set, the "Make Binary" command will respect
> it when converting to a binary image. So in a macro, you can do something
> like:
>
> IJ.setThreshold(imp, 85, 170);
> IJ.run(imp, "Make Binary", "thresholded remaining black");
> // be careful whether your data has a black background or a white one,
> though.
>
> You can also have total control over the binarization using a custom macro.
> Run Process > Math > Macro and try e.g.:
>
> if (v<=104) v=0; else v=255
>
> HTH,
> Curtis
>
>
> On Mon, Sep 9, 2013 at 9:11 AM, Rainer M. Engel <[hidden email]> wrote:
>
>> Dear all,
>>
>> I have to convert my 8bit images to binary images, containing only black
>> and white (0 & 255) pixels. That is OK and offers a wide range of
>> processing possibilities.
>>
>> Imagine I have these two images (both are binary)
>> https://dl.dropboxusercontent.com/u/414433/imagej/bitbin/09.png
>> https://dl.dropboxusercontent.com/u/414433/imagej/bitbin/12.png
>>
>> I didn't forget the settings..
>> //important values to set
>> run("Colors...", "foreground=white background=black selection=yellow");
>> run("Options...", "iterations=1 black edm=Overwrite count=1");
>>
>> But image 12.png is inverted if I make it binary again. This happens
>> even if I blur it before that. I understand that Making Binary is some
>> sort of threshold process, which may in some situation swap or invert my
>> image.
>>
>> Is there a way to make an image binary with an expression or formula,
>> all pixels darker 128 become 0, brighter ones become white?
>>
>> Best Regards,
>> Rainer
>>
>>
>> --
>> Rainer M. Engel, Dipl. Digital Artist
>> scientific|Media GbR
>> Pichelsdorfer Str. 143
>> 13595 Berlin
>>
>> --
>> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>>
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

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