Sunday, 11 December 2011

Changing the bit depth of images using ImageMagick

Today I wanted to create a simple black-and-white version of a grayscale image that I have. This is pretty easily done in Matlab (you can scale the image to values between 0 and 1 and use round()), but I was guessing there was probably already some simple way to do it in ImageMagick - and there is!

This is the original version of the image (from the great graphical novel series "Bone"):


To convert it to a 3-bit image (8 levels), I used the -depth switch with the convert command:

convert bone.jpg -colorspace gray -depth 3 bone3bit.jpg


And similarly, for black-and-white (1 bit image):

convert bone.jpg -colorspace gray -depth 1 bone1bit.jpg






1 comments:

buyi wen said...

I'm not a developer, I always use this free online image converter to convert image.

Post a Comment