Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I guess your best bit is the radio between histogram and number of pixel. A cartoon-line image trend to have less number of color then the real-life one.</p> <p>You can use</p> <pre><code>COLORS=`convert picture.jpg -format %c histogram:info:- | wc -l`</code></pre> <p>to count how many colors the picture have. And use a command like:</p> <pre><code>WIDTH=`jpeginfo picture.jpg | sed -r "s/.* ([0-9]+) x.*/\1/"`</code></pre> <p>and</p> <pre><code>HEIGHT=`jpeginfo picture.jpg | sed -r 's/.*x ([0-9]+) .*/\1/'`</code></pre> <p>to extract width and height.</p> <p>Then use this command to find the ratio:</p> <p><code>echo $WIDTH $HEIGHT $COLORS | awk '{ print $3/($1 * $2);}'</code></p> <p>Then it is up to you to define what ratio is qualified as cartoon-like and what is not. For Cartoon-like, the ratio is mostly lower than the real-life one.</p> <p>Just a thought.</p> <p><b>EDIT:</b> I just saw your comment that you don't want to know how just an exiting one. So just ignore my answer then.</p> <p><b>EDIT 2:</b> I modify it a bit to make it easier to see.</p> <p><b>NOTE 1:</b> You should notice that I swap the ratio as the number of pixels is always much bigger than the number of colors so the previous program results in a lower number. That is why you can hardly distinguish them.</p> <p><b>NOTE2:</b> I also change from "jpeginfo" to "identity" as <code>jpeginfo</code> can only do jpg and it is not a part of ImageMagick.</p> <p>~/test/CheckCartoon.sh <pre><code>#!/bin/sh</p> <p>IMAGE=$1 COLORS=<code>convert $IMAGE -format %c histogram:info:- | wc -l</code> WIDTH=<code>&lt;b&gt;identify&lt;/b&gt; $IMAGE | sed -r "s/.* ([0-9]+)x[0-9]+ .*/\1/"</code> HEIGHT=<code>&lt;b&gt;identify&lt;/b&gt; $IMAGE | sed -r 's/.* [0-9]+x([0-9]+) .*/\1/'</code> RATIO=<code>echo $WIDTH $HEIGHT $COLORS | awk '{ print &lt;b&gt;($1 * $2)/$3&lt;/b&gt;;}'</code> echo $RATIO | awk '{ printf "%020.5f",$1 }' </pre></code></p> <p>~/test/CheckAll.sh <pre><code>#!/bin/sh</p> <p>cd images FILES=<code>ls</code> for FILE in $FILES; do IsIMAGE=<code>identify $FILE 2&gt;&amp;1 | grep " no decode delegate " | grep -o "no"</code> if [ "$IsIMAGE" = "no" ]; then continue; fi</p> <pre><code>IsIMAGE=`identify $FILE 2&gt;&amp;1 | grep " Improper image header " | grep -o "Improper"` if [ "$IsIMAGE" = "Improper" ]; then continue; fi echo `.././CheckCartoon.sh $FILE` $FILE </code></pre> <p>done</p> <p>cd .. </pre></code></p> <p>Now for testing you copy files here.<br/></p> <p>Pic 1: <a href="http://dl.getdropbox.com/u/1961549/StackOverflow/SO1518347/Cartoon-01.jpg" rel="noreferrer">~/test/images/Cartoon-01.jpg</a><br/></p> <p>Pic 2: <a href="http://dl.getdropbox.com/u/1961549/StackOverflow/SO1518347/Cartoon-02.png" rel="noreferrer">~/test/images/Cartoon-02.png</a><br/></p> <p>Pic 3: <a href="http://dl.getdropbox.com/u/1961549/StackOverflow/SO1518347/Cartoon-03.gif" rel="noreferrer">~/test/images/Cartoon-03.gif</a><br/></p> <p>Pic 4: <a href="http://dl.getdropbox.com/u/1961549/StackOverflow/SO1518347/Real-01.jpg" rel="noreferrer">~/test/images/Real-01.jpg</a><br/></p> <p>Pic 5: <a href="http://dl.getdropbox.com/u/1961549/StackOverflow/SO1518347/Real-02.jpg" rel="noreferrer">~/test/images/Real-02.jpg</a><br/></p> <p>Pic 6: <a href="http://dl.getdropbox.com/u/1961549/StackOverflow/SO1518347/Real-03.jpg" rel="noreferrer">~/test/images/Real-03.jpg</a><br/> <br/></p> <p><a href="http://dl.getdropbox.com/u/1961549/StackOverflow/SO1518347/Images.png" rel="noreferrer">http://dl.getdropbox.com/u/1961549/StackOverflow/SO1518347/Images.png</a> <br /> <br /></p> <p>Then I run <code>./CheckAll.sh | sort</code> (in <code>test</code> folder). Here is want I got.</p> <pre><code>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 </code></pre> <p>As you can see the result is generally good. You can use number like 15 as a separation. </p> <p><code>Cartoon-01.jpg</code> is a drawing but it looks like a quite realistic one so it may be easily confused. Also <code>Real-01.jpg</code> is a picture of my girlfriend standing in front of an ocean so the number of colors is less than usual. This come to no surprise why the confusion happens.</p> <p>What I show you here is still a raw theory. If you really want a conclusive indication you may have to find number of metrics and compare them. For example, the degree of local contrast.</p> <p>Hope this will helps.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload