How to Expand contour similar dilatation of contour?

I want to expand contour similar to dilation of contour but when I expand the contour the new contour points from original contour for each peer to peer point is not equal.

How can the problem be solved?

In the below shape the green ellipse is original contour and the red ellipse is the expanded contour by scale =1.2

edit retag close merge delete

Do you already have an efficient way to dilate a contour, with the initial contour in the form of a vector of points?

( 2014-02-24 07:48:16 -0600 )edit

Sort by ยป oldest newest most voted

If you have a contour as a vector of points and you want to scale it up or down then you need to find center of mass of that contour, and then for each point:

• map it to new coordinates where 0,0 is in center of contour (by substraction of position of the center on x and y)
• scale position by multiplying it, something like point.x *= 1.05; point.y *= 1.1; means 5% bigger on x axis and 10% on y axis (exact way depends on programming language)
• map it back to previous coordinates by adding back position of the center

To find center of mass you can simple take an average from all points location or calculate centroid from contour moments, see documentation on topic of contour moments

more