Extract landscape lines from image [closed]

asked 2018-05-26 09:37:10 -0500

sazr gravatar image

My usecase is I would like to extract certain contours/edges from a landscape image. The purpose is to simply store the contours' x,y vertices. Please see here for the original image, the desired result and the results I am getting. https://imgur.com/a/ZFQYLOv

I know of a couple of ways to extract edges but all of them also identify unwanted edges aswell. What is the best way to achieve my objective? My ideas are below although they are not achieving my objective. BTW I am using OpenCV.

  • Use canny, sobel or any edge detection method and allow detection of unwanted edges. Dilate the image to join edges. Run cv::findContours() then find the longest contours. Presumably the longest contours are my desired contours.
  • Remove 'weak' edges by blurring the original image with a big kernel. Then run Sobel, cv::findContours() on the gradient magnitude. The problem is this assumes my landscape lines/depth lines are always strong which is not always the case.
  • Is there a filter I can run on my Gradient Magnitude image that preserves strong gradient magnitude and removes weak gradients?
edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by sturkmen
close date 2020-10-11 10:17:23.043986