title: Finding waters edge using OpenCV and Python accurately
body: <p>I have been working on trying to detect the edge of the water using OpenCV/Python, and the results I am getting are fairly inaccurate and there is no robustness. 
  This is what I have achieved so far:
  <a href="https://i.stack.imgur.com/HAFOd.jpg" rel="nofollow noreferrer">Original Image, output image</a></p>
  
  <p><a href="https://i.stack.imgur.com/lCJBB.png" rel="nofollow noreferrer">Canny Edge detection</a></p>
  
  <p>What I am currently doing is setting some variables (the level of Gaussian blur, the sigma used for the Canny edge detection, and the maximum deviation which the level measured can change between each point), performing an 'automatic' Canny edge detection (where the median pixel intensity is measured and used to form the lower and upper boundaries), then moving from the bottom left hand corner upwards to find the first 'white' pixel. This is done in x intervals of five the entire length of the frame. </p>
  
  <p>The average y value of the points is the calculated. Each point is then tested to see if it deviates too far from the average pixel, with the deviation limit being set earlier. The remaining points are then drawn on the image as the blue line. The average value of the drawn pixels is recorded at each frame. </p>
  
  <p>After 30 frames, the average of the averages is calculated and drawn as the red line, which is then assumed to be the 'real' water height. </p>
  
  <p>Has anyone have any ideas on a better way to do this? What would make the edge of the water stand out more? This method works on most footage I have recorded, but with poor results. </p>
  
  <p>Thanks in advance. </p>