2 edited tags
| link
source | link

Fit best polygon to a discrete contour

I have a discrete contour represented by a set of points. The contour looks like a polygon but if you zoom you see that the edges are rugged (that's because it was obtained while working on a finite differences grid)

I would like to fit a polygon to this contour (which is closest in the least-squares sense). Are there any simple known algorithms to do this?

enter image description here