How to convert pixel segmentation to polylines?
I have a pixel segmentation created from a superpixel algorithm such as this. So for each pixel I have a label for which "superpixel" (i.e. group) it belongs to. I would like to convert the boundaries between superpixels into polylines instead of pixels so that they may be simplified with the Douglas-Peucker algorithm.
My problem is that I cannot figure out how to go from the superpixel labels to polylines. It is trivial to draw the superpixel boundaries (see attached image) but I am having trouble understanding how to convert those boundaries to polylines. Any suggestions would be really appreciated!
As far as I know, a polygon is basically a
vector<Points>
, so why not loop over points and push them into avector<Points>
you define? This means you can decide which points will belong to which polygon.