Image Classification - Detecting an image is cartoon-like

前端 未结 4 1908
-上瘾入骨i
-上瘾入骨i 2021-02-06 14:05

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 mig

4条回答
  •  不要未来只要你来
    2021-02-06 14:50

    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.

提交回复
热议问题