Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find an Equivalent point in a Scaled down image?

Tags:

c++

opencv

I would like to calculate the corner points or contours of the star in this in a Larger image. For that I'm scaling down the size to a smaller one & I'm able to get this points clearly. Now How to map this point in original image? I'm using opencv c++. enter image description here

like image 892
Balaji R Avatar asked Oct 20 '25 04:10

Balaji R


1 Answers

Consider a trivial example: the image size is reduced exactly by half.

So, the cartesian coordinate (x, y) in the original image becomes coordinate (x/2, y/2) in the reduced image, and coordinate (x', y') in the reduced image corresponds to coordinate (x*2, y*2) in the original image.

Of course, fractional coordinates get typically rounded off, in a reduced scale image, so the exact mapping is only possible for even-numbered coordinates in this example's original image.

Generalizing this, if the image's width is scaled by a factor of w horizontally and h vertically, coordinate (x, y) becomes coordinate(x*w, y*h), rounded off. In the example I gave, both w and h are 1/2, or .5

You should be able to figure out the values of w and h yourself, and be able to map the coordinates trivially. Of course, due to rounding off, you will not be able to compute the exact coordinates in the original image.

like image 127
Sam Varshavchik Avatar answered Oct 22 '25 18:10

Sam Varshavchik