Separate out Individual Colors in an Image

ImageMagick’s convert utility is the Swiss-Army knife of command-line image editing. I won’t get into all of the amazing tricks it can accomplish (you can even make animations and anaglyphs), but instead share a cool new thing I learned to do with it today. This command will generate a grayscale image that contains only the values from the “channel” you specify (R, G, B):

convert colorimage.jpg -channel R -separate grayimage-red.jpg
convert colorimage.jpg -channel G -separate grayimage-green.jpg
convert colorimage.jpg -channel B -separate grayimage-blue.jpg

So for example, you can take this good-looking guy:


and split him into

Red Green Blue

You may be surprised to learn that this has direct bearing on my Geology Master’s thesis. I’m analyzing grayscale images of layered rocks to determine if they contain evidence of past life—and the way you convert from color to grayscale may matter (we’re going to test this).