views:

565

answers:

4

I have a large amount of JPEG thumbnail images ranging in size from 120x90 to 320x240 and I would like to classify them as either Real Life-like or Cartoon-like.

How might one do this using ImageMagick's utilities: convert, compare, identify? Or are there other programs out there that will do the trick?

A: 

This is an Image-classification problem which AFAIK ImageMagick will NOT be able to do.

opencv (which deals with computer vision) might be of more help, for some idea on how an "image classifier" is trained with training data.

Alphaneo
+13  A: 
NawaMan
+1, great answer. simple and logical.
Peter
I ran your solution against a sample set of 200 pictures for each set (cartoon, real) and there is no clear distinction between the classifications.
kingb
Please see my edit.
NawaMan
+1 Wonderful answer
Alphaneo
I ran this solution again, with your modifications but it still the same. I believe the sample sizes you're using, compared to what I'm using (120x90 - 320x240), is the reason there's little distinction between the two.
kingb
I've just seen that your picture resolution is quite small. Because this method is relies on collective information (histogram), it is not suitable for small size picture as the numbers of colors in each picture are not so much different. In this case, I really don't know what to help you. Sorry.
NawaMan
+6  A: 
Ivan
+2  A: 

As a first pass I would try computing the entropy of the color histogram of the image. Cartoon-like images should have fewer shades of different colors, and thus a lower entropy.

This is similar to what NawaMan proposed, but this method goes one step further. The number of colors over the number of pixels may not be enough. There may be jpeg artifacts, for instance, that artificially increase the number of colors in the image, but only for a few pixels. In this case most pixels in the image would still have very few colors, which would correspond to low entropy.

Let's say you start with an RGB image. For each pixel the R, G, and B values range from 0 to 255.
You can divide this range into n bins, where n can be 16 for example. The you would count how many pixels fall into each one of these 3-dimensional bins. Then you would need to divide the values of the bins by the total number of pixels, so that your histogram sums up to 1. Then compute the entropy, which is - sum_i p_i * log(p_i), where p_i is the value of the ith bin.

Try it with different values for n, and see if you can separate the real images from cartoons.

Dima