title: Distance transform - the function does not work properly
body: <p>I am trying to get the distance transform image, but I am getting a bad result. </p>
  
  <p>Image:</p>
  
  <p><a href="https://i.stack.imgur.com/0X50f.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0X50f.jpg" alt="enter image description here"></a></p>
  
  <p>Code:</p>
  
  <pre><code>import cv2
  import imutils
  import numpy as np
  
  photo = 'dog.jpg'
  
  img = cv2.imread(photo)
  ybprc = cv2.cvtColor(img, cv2.COLOR_BGR2YCrCb)
  inrangeHsv = cv2.inRange(ybprc, np.array([0, 135, 85]), np.array([255, 180, 135]))
  retval, otsu = cv2.threshold(inrangeHsv, 150, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)
  cnts = cv2.findContours(otsu.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
  cnts = imutils.grab_contours(cnts)
  c = max(cnts, key=cv2.contourArea)
  mask = cv2.drawContours(otsu, [c], -1, (0,255,0), 2)
  out = cv2.distanceTransform(mask, distanceType=cv2.DIST_L2, maskSize=5)
  
  cv2.imshow("distance_transform", out)
  cv2.waitKey(0)
  cv2.destroyAllWindows()
  </code></pre>
  
  <p>And result is:
  <a href="https://i.stack.imgur.com/NFfRE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NFfRE.png" alt="enter image description here"></a></p>
  
  <p>But the result should be more like:</p>
  
  <p><a href="https://i.stack.imgur.com/xPPbu.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xPPbu.gif" alt="enter image description here"></a></p>
  
  <p>How should I fix it? </p>