Ask Your Question
4

How to Expand contour similar dilatation of contour?

asked 2013-01-15 05:03:18 -0600

updated 2013-01-18 02:05:46 -0600

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

image description

edit retag flag offensive close merge delete

Comments

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

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

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-07-11 16:22:34 -0600

Zbyszek gravatar image

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

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-01-15 05:03:18 -0600

Seen: 5,699 times

Last updated: Jan 18 '13