How to know coordinates in a real image from a scaled image.

Posted by ocell on Stack Overflow See other posts from Stack Overflow or by ocell
Published on 2010-06-07T09:48:47Z Indexed on 2010/06/07 9:52 UTC
Read the original article Hit count: 300

Filed under:
|
|
|
|

Hi folks,

First of all thanks for your time reading my question :-)

I have an original image (w': 2124, h': 3204) and the same image scaled (w: 512, h: 768). The ratio for width is 4.14 (rw) and the ratio for height is 4.17 (rh).

I'm trying to know the coordinates (x', y') in the original image when I receive the coordinates in the scaled image (x, y). I'm using the formula: x' = x * rw and y' = y * rh. But when I'm painting a line, or a rectangle always appears a shift that is incremented when x or y is higher.

Please anybody knows how to transform coordinates without loosing of accuracy.

Thanks in advance! Oscar.

© Stack Overflow or respective owner

Related posts about c++

Related posts about image