0

I need to do lengthy processing on a large image file.So before processing i resize it.At the end of the processing coordinates of a rectangle within the resized image is returned.How can i translate this rectangle/coordinates of the rectangle to a rectangle in the non resized full size image?

techno
  • 6,100
  • 16
  • 86
  • 192
  • Possible duplicate of [How can I transform XY coordinates and height/width on a scaled image to an original sized image?](https://stackoverflow.com/questions/4994690/how-can-i-transform-xy-coordinates-and-height-width-on-a-scaled-image-to-an-orig) – Alex K. Jul 03 '17 at 11:19

1 Answers1

0

Resizing is linear transformation, so new coordinate of some point is calculated as

 X_New = Ax * X_Old + Bx

To get it back, just use reverse transform

 X_Old = (X_New - Bx) / Ax
MBo
  • 77,366
  • 5
  • 53
  • 86
  • They are defined by your resizing – MBo Jul 04 '17 at 13:08
  • For example i have to translate a point (x,y) within an resized image(smaller size) to the larger image .. i do the following `xt=(x-largeimagewidth)/smallimagewidth` ? i'm i right? could you add some more explanation. – techno Jul 04 '17 at 13:12
  • If you extend image without shifting (no B coefficient) `x_large = x_small * largeimagewidth / smallimagewidth` and vice versa `x_small = x_large * smallimagewidth / largeimagewidth` – MBo Jul 04 '17 at 13:25