Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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