title: OpenCV: fit the detected edges
body: <p>I detected the edges of a water wave by using canny edge detection. However, I want to fit a curve for this edge. Is that possible in OpenCV? </p>
  
  <p>Here is the image before edge detection:
  <a href="https://i.stack.imgur.com/I1tYz.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/I1tYz.jpg" alt="Image before edge detection."></a></p>
  
  <p>Here is the result of the edge detection operation:
  <a href="https://i.stack.imgur.com/g828k.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/g828k.png" alt="Result after detecting"></a></p>
  
  <p>The code was copied from an example in the OpenCV tutorials:</p>
  
  <pre><code>import cv2
  import numpy as np
  from matplotlib import pyplot as plt
  
  img = cv2.imread('BW.JPG',0)
  edges = cv2.Canny(img,100,200)
  
  plt.plot(1),plt.imshow(edges,cmap = 'gray')
  plt.title('WAVE')
  plt.show()
  </code></pre>