Page 1 of 1
Colour to Black and white
Posted: 2010-01-07T21:35:59-07:00
by rkayssar
Hi,
i have a couple of color TIF images (Green, Pink, and Yellow). i need to convert to black and white through unix command line.
i tried the following:
convert +compress -monochrome ImageName Imageout
convert +compress -type Bilevel ImageName Imageout
commands and they get only converted to grayscale.
My Question is there a command i can run to convert all the images to Black and white without setting a threshold as they differ between images
Thanks
Re: Colour to Black and white
Posted: 2010-01-07T22:20:05-07:00
by fmw42
try changing the order of your commands to the proper syntax with the input before the operators. see
http://www.imagemagick.org/Usage/basics/#why
try
convert imagein.tif -colorspace gray -colors 2 +dither -type bilevel imageout.tif
or
convert imagein.tif -monochrome -type bilevel imageout.tif
but monochrome will always dither.
be sure to save your result as tif as gif and png may not support bilevel image types
see
http://www.imagemagick.org/Usage/quantize/#monochrome
http://www.imagemagick.org/Usage/quantize/#two_color
By the way, your message probably should have been posted to the User's forum, but not a big deal
Re: Colour to Black and white
Posted: 2010-01-07T22:36:15-07:00
by rkayssar
Hi Thanks for that
unfortunately the pink and the green color came out completely white using the second command
and the first command shows no image
Re: Colour to Black and white
Posted: 2010-01-07T22:41:52-07:00
by fmw42
Post a link to your image and explain what you would like to have happen and I will experiment with it. But thresholding in various methods is tricky and image dependent.
You can try some of my various (bash unix) thresholding scripts (although they may not necessarily set the type to bilevel, they will result in black and white only). So you may need to change to grayscale first (-colorspace gray) and set the type to bilevel afterwards (-type bilevel)
see my web site link below and also
http://www.fmwconcepts.com/imagemagick/ ... /index.php
It is late for me now, so I will try tomorrow if you post a link to your image(s).
Re: Colour to Black and white
Posted: 2010-01-10T16:33:41-07:00
by rkayssar
Hi,
i am working on getting those images for you ...really appreciate your help