Image color/grayscale classification

graphicsimage manipulationrecognition

I am trying to classify a set of images into grayscale or color groups. I have been using ImageMagic to do that, comparing the color image to a grayscale version of itself and then using the Peak Error to determine if it is a grayscale image, as shown here:

http://www.imagemagick.org/Usage/compare/#type_general

This is working, however, it is producing false results for a lot of back and white images. I have tracked this issue down and I believe it is being caused by pseudo-black pixels (e.g.: rgb(0,0,5)). These psuedo black pixels appear as full color, because they technically are.

Is there a better way to classify these images?

What would you suggest I do to get rid of these false results?

Best Answer

Convert the images to another color space like HSV and than just check the S component. S stands for saturation and the saturation should be (nearly) 0 for all grayscale images. Here is the documentation from ImageMagick: http://www.imagemagick.org/script/color.php