title: Perfecting Image to cartoon conversion using OpenCV
body: <p>I am trying to convert a given face image to cartoon format, and able to achieve quite far.
  The image conversion achieved by me is as follows ::</p>
  
  <p><strong>ORIGINAL</strong></p>
  
  <p><a href="https://i.stack.imgur.com/lZ3kt.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lZ3kt.jpg" alt="enter image description here"></a></p>
  
  <p><strong>AfterConversion</strong></p>
  
  <p><a href="https://i.stack.imgur.com/1GHoh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1GHoh.png" alt="enter image description here"></a></p>
  
  <p>So what I did for the conversion was following :: </p>
  
  <ul>
  <li><code>DownScale</code> the image, <code>Bifilter</code> and <code>Upscale</code>.</li>
  <li>Convert <code>RGB</code> to <code>GRAYSCALE</code> and apply <code>Median Blur</code>.</li>
  <li>Apply <code>Adaptive Threshold</code>, convert <code>GRAYSCALE</code> to <code>RGB</code>.</li>
  <li><code>Bitwise AND</code> the current image with the image obtained in first step (bifiltered one).</li>
  <li>Repeat step one again, just that after downscaling and bifilter application apply one more bifilter with value of <code>d(diameter)</code> and <code>sigma</code> to be high.</li>
  </ul>
  
  <p>So, the image that I am getting as you can see different patches of color on the face, since this image is of high quality so the color transition doesn't look bad, but in some image on the face the color transition can be as bad as this :</p>
  
  <p><a href="https://i.stack.imgur.com/jizWz.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jizWz.jpg" alt="enter image description here"></a></p>
  
  <p>As you can see on the forehead there is color transition (because of lighting may be) and its not subtle and very sharp which should be in a cartoonised avatar of the image.</p>
  
  <p>The color smoothness and transitions what I am actually trying to achieve is this ::</p>
  
  <p><a href="https://i.stack.imgur.com/OJyBT.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OJyBT.jpg" alt="enter image description here"></a></p>
  
  <p>So what else should I do to achieve this smoothness. I can share the values of the various matrices that I am using in the different algorithms as mentioned above.</p>
  
  <p>Thanks in advance.</p>