user2721513
user2721513

Reputation: 13

Relationship between original and resized image (C++/OpenCV)

I have a big (ca. 4000x3000) image on some (known) points of which I have to perform some operations, by clicking on them.

So, here's the problem: in order to visualize it, I have to resize it (making it smaller), but then I am uncapable of linking the coordinates of the resized image, on which I click, with the coordinates of the "original" image, which I have to modify! (It does not, obviously, have to be precise! I could accept errors on, let's say 10px. But I get hundreds of pixel of error..!)

How can I solve that?

I am using OpenCV with C++, the command I am using by now is resize() that I found here with fx=fy=0.25.

Obviously, multiplying (or dividing..) everything by 4 did not work well.. why?

(Or to be more precise: it worked on an axis only.

Thank you in advance for your help!

Upvotes: 1

Views: 678

Answers (1)

Andrey  Smorodov
Andrey Smorodov

Reputation: 10852

Usual way for solving such problems is output somewhere small window with piece of image displayed in real scale and user, when need precise positioning works within this small window. Simultaneously in scaled image displayed rough position of coursor. Mouse moves in coordinates of large image, then computed where is small window (small square around mouse position), cut it and display somewhere, then scale coordinates and display cursor it evaluated position. Using such approach you will get per pixel precision.

Upvotes: 2

Related Questions