1 | initial version |
if topleft corner (M) of ROI is (xr,yr) in orignal image (origin O) and gravity center (G) of contour is(xg,yg) in roi coordinates then gravity center coordinates in orignal image is (xr+xg,yr+yg).
or
if topleft corner of ROI is (xr,yr) in orignal image and gravity center of contour is(xg,yg) in image coordinates then gravity center coordinates in roi is (-xr+xg,-yr+yg).
OM+MG=OG
2 | No.2 Revision |
if topleft corner (M) of ROI is (xr,yr) in orignal image (origin O) and gravity center (G) of contour is(xg,yg) in roi coordinates then gravity center coordinates in orignal image is (xr+xg,yr+yg).
or
if topleft corner of ROI is (xr,yr) in orignal image and gravity center of contour is(xg,yg) in image coordinates then gravity center coordinates in roi is (-xr+xg,-yr+yg).
OM+MG=OG
If you want to move all points belonging to a contour :
Point d(100,200);// translate vector d
for (int i=0;i<contour.size();i++
contour[i] += d;