Image classification. Image detection is cartoony

I have a large number of JPEG thumbnail images ranging in size from 120x90 to 320x240, and I would like to classify them in both Real Life and cartoon style.

How to do using ImageMagick utilities: convert, compare, identify? Or are there other programs that will do the trick?

+5
source share
4 answers

In theory:

- "" . , "" , . , , ( ) :

isNotACartoonIndex = mean( originalImage - smooth(originalImage) )

(.. ) , . ( ) ().

, .

:

/ : Original Filered

OpenCV cvSmooth CV_BILATERAL.

, Hue HSV. , RGB HSV.

: ImageMagick .

+11

, - . , .

COLORS=`convert picture.jpg  -format %c histogram:info:- | wc -l`

, . :

WIDTH=`jpeginfo picture.jpg | sed -r "s/.* ([0-9]+) x.*/\1/"`

HEIGHT=`jpeginfo picture.jpg | sed -r 's/.*x ([0-9]+)  .*/\1/'`

.

, :

echo $WIDTH $HEIGHT $COLORS | awk '{ print $3/($1 * $2);}'

, , . , , .

.

EDIT: , , . .

EDIT 2: , .

1: , , , , . .

2: "jpeginfo" "identity", jpeginfo jpg ImageMagick.

~//CheckCartoon.sh

#!/bin/sh

IMAGE=$1 COLORS=convert $IMAGE -format %c histogram:info:- | wc -l WIDTH=<b>identify</b> $IMAGE | sed -r "s/.* ([0-9]+)x[0-9]+ .*/\1/" HEIGHT=<b>identify</b> $IMAGE | sed -r 's/.* [0-9]+x([0-9]+) .*/\1/' RATIO=echo $WIDTH $HEIGHT $COLORS | awk '{ print <b>($1 * $2)/$3</b>;}' echo $RATIO | awk '{ printf "%020.5f",$1 }'

>

~//CheckAll.sh

#!/bin/sh

cd images FILES=ls for FILE in $FILES; do IsIMAGE=identify $FILE 2>&1 | grep " no decode delegate " | grep -o "no" if [ "$IsIMAGE" = "no" ]; then continue; fi

IsIMAGE=`identify $FILE 2>&1 | grep " Improper image header " | grep -o "Improper"`
if [ "$IsIMAGE" = "Improper" ]; then continue; fi

echo `.././CheckCartoon.sh $FILE` $FILE

cd..

>

.

Pic 1: ~/test/images/Cartoon-01.jpg

Pic 2: ~/test/images/Cartoon-02.png

Pic 3: ~/test/images/Cartoon-03.gif

Pic 4: ~/test/images/Real-01.jpg

. 5: ~/test/images/Real-02.jpg

. 6: ~/test/images/Real-03.jpg

http://dl.getdropbox.com/u/1961549/StackOverflow/SO1518347/Images.png


./CheckAll.sh | sort ( test). , .

00000000000003.31362 Real-03.jpg
00000000000004.61574 Real-02.jpg
00000000000009.89920 Cartoon-01.jpg
00000000000013.05870 Real-01.jpg
00000000000020.55470 Cartoon-03.gif
00000000000032.21900 Cartoon-02.png

, . 15 .

Cartoon-01.jpg - , , . Real-01.jpg - , , . , .

, , - . , , , . , .

, .

+16

. , , .

, NawaMan, . . , jpeg-, , . , .

, RGB. R, G B 0 255.
n , n 16, . , . , 1. , is - sum_i p_i * log (p_i), p_i - i- .

n , .

+4

, AFAIK ImageMagick .

opencv (which deals with computer vision) may be more useful for some idea of ​​how the “image classifier” is trained with training data.

0
source

All Articles