Image Classification - Detecting an image is cartoon-like

前端 未结 4 1858
-上瘾入骨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:38

    In theory:

    One way to discriminate between cartoon and natural scene images is to compare a given image to its "smoothed" self. The motivation behind this is that a "smoothed" cartoon image statistically will not change much, where as a natural scene image will. In other words, take an image, cartoonify (i.e. smooth) it and subtract the result from the original:

    isNotACartoonIndex = mean( originalImage - smooth(originalImage) )
    

    This difference (i.e. taking its mean value) will give the level of change caused by the smoothing. The index should be high for non-smooth original (natural scene) images and low for smooth original (cartoony) images.

    An SO question already discusses how to cartoonify images.

    In practice:

    I would suggest doing the smoothing/cartoonifying with bilateral filtering:

    Bilateral filtering can be done with OpenCV using the cvSmooth function with the CV_BILATERAL parameter.

    As for subtracting the cartoonyfied image from the original, I would do that with the Hue channel of the HSV images. This means you need to first convert both images from RGB to HSV.

    As a side note, wanting to achieve this with an ImageMagick workflow, might be unnecessarily complicated.

提交回复
热议问题