Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

Are there any applications that will have cartoon classification capabilities?

This application should work on Linux, and should take an image path on the command-line and return either 0 or 1 (echo $?).

share|improve this question
2  
What exactly are you after? A program that will allow you to manually tag images, or a program that will automatically tag pictures as either cartoon or real-life? Also, what operating system? –  David Pearce Oct 5 '09 at 5:23
    
I've edited my submission to include answers to your questions. –  user13212 Oct 5 '09 at 5:40
    
I think you need to be more specific about what you mean by "Cartoon like". If they are line drawings with solid fills, it's farily simple. If they contain shading, it gets a lot harder. –  rjmunro Jan 20 '11 at 10:24

2 Answers 2

I think you could do something like this with Imagemagick. It has image quantization and histogram analysis features that you'll probably need to give this a real treatment.

The simplest thing to do is count the number of unique colors in each picture - cartoons should generally have fewer than photos. This may work as is if your search space is fairly simple. i.e. differentiating simple cartoons form color photos. If you have 'fancy' cartoons, you may have to add additional checks. I added an extra echo for RGB vs. Grey color space before checking each image.

A more sophisticated test might involve checking the histogram, either total or in RGB space of each image.

#!/bin/bash

for i in `ls *.jpg`
do
    echo "$i is `convert $i -format \"%[colorspace]\" info:`"
    x=`convert $i -unique-colors txt:- | wc -l`

    if [ $x -le 512 ]; then
        echo "$i is cartoon like ($x)"
    elif [ $x -le 1024 ]; then
        echo "$i is a bw photo ($x)"
    else
        echo "$i is real life-like ($x)"
    fi
done

The main complication is separating complex computer animations from b&w photos. A B&W photo may have relatively few unique colors in it, while a sophisticated cartoom may have thousands due to computer aided shading. You'll probably need to experiment with the thresholds for 'X' depending on what your images look like.

share|improve this answer
1  
"cartoons should generally have fewer than photos" .. not always true, think of color gradients. i would try to use an edge-detecor (google sobel, laplace etc) .. and then use that information to decide, if its a cartoon or not. real life pictures tend to have much more noise in such 'edge pictures' en.wikipedia.org/wiki/Sobel_operator –  akira Oct 5 '09 at 9:02
    
I agree, which is why I prefaced it with 'the simplest thing'. With no information on what these cartoons were like, I went with the simplest thing that just might work. –  DaveParillo Oct 5 '09 at 15:25
    
This topic is specifically discussed on the imagemagick web site: imagemagick.org/Usage/compare/#animation . An outline of a solution is described, but not a concrete example. Maybe I'll write one tonight... –  DaveParillo Oct 5 '09 at 16:07

Provided that you have images that you can show to school children and there are lots of cartoons.

You can go to a school and use HUMAN COMPUTING.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.