Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Obtain polylines only from cv::findContours()?

When I run cv::findContours() on my thresholded image I am getting the contours I want but the contours are polygons not polylines.

Is it possible to make cv::findContours() return contours as polylines not polygons? If not, is there an OpenCV way to convert polygons to polylines?

Below is my threshold image that I use for findContours and also the result - you can see the largest contour I found is a polygon but I am hoping it to be a polyline traversing the mountain ridge.

findContours(thresh, contours, CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE);

enter image description here enter image description here

Obtain polylines only from cv::findContours()?

When I run cv::findContours() on my thresholded image I am getting the contours I want but the contours are polygons not polylines.

Is it possible to make cv::findContours() return contours as polylines not polygons? If not, is there an OpenCV way to convert polygons to polylines?

Below is my threshold image that I use for findContours and also the result - you can see the largest contour I found is a polygon but I am hoping it to be a polyline traversing the mountain ridge.ridge. I don't believe eroding the threshold image is the best way to obtain a polyline.

findContours(thresh, contours, CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE);

enter image description here enter image description here

Obtain polylines only from cv::findContours()?

When I run cv::findContours() on my thresholded image I am getting the contours I want but the contours are polygons not polylines.

Is it possible to make cv::findContours() return contours as polylines not polygons? If not, is there an OpenCV way to convert polygons to polylines?

Below is my threshold image that I use for findContours and also the result - you can see the largest contour I found is a polygon but I am hoping it to be a polyline traversing the mountain ridge. I don't believe eroding the threshold image is the best way to obtain a polyline.

findContours(thresh, contours, CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE);

enter image description here enter image description here

Unprocessed image:

image description