title: How can I improve color thresholding output?
body: <ul>
  <li>See: <a href="https://analyticsindiamag.com/converting-an-image-to-a-cartoon/" rel="nofollow noreferrer">Converting An Image To A Cartoon Using OpenCV</a></li>
  </ul>
  <p>In the above article they have the following image:</p>
  <p><a href="https://i.stack.imgur.com/owo5P.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/owo5P.png" alt="enter image description here" /></a></p>
  <p>And, they wanted to obtain an output like the following:</p>
  <p><a href="https://i.stack.imgur.com/SLIe1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SLIe1.png" alt="enter image description here" /></a></p>
  <p>I ran the following script:</p>
  <pre><code>import cv2
  
  window_name = 'image'
  
  img = cv2.imread(&quot;photo.png&quot;)
  
  cv2.imshow(window_name, img)
  cv2.waitKey(0)
  
  
  gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
  gray = cv2.medianBlur(gray, 5)
  edges = cv2.adaptiveThreshold(gray, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY, 9, 9)
  
  cv2.imshow(window_name, edges)
  cv2.waitKey(0)
  
  color = cv2.bilateralFilter(img, 9, 250, 250)
  cartoon = cv2.bitwise_and(color, color, mask=edges)
  
  cv2.imshow(window_name, cartoon)
  cv2.waitKey(0)
  </code></pre>
  <p>Firstly, the script is very slow.</p>
  <p>Secondly, the output is not what they promised would be:</p>
  <p><a href="https://i.stack.imgur.com/aHaj7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aHaj7.png" alt="enter image description here" /></a></p>
  <p>How can I fix these two issues?</p>