Rect_<int> and Rect_<float> in image coord system.

asked 2019-04-29 02:38:48 -0600

LuisK gravatar image

updated 2019-04-30 02:55:20 -0600

Hello,

I know that the discrete image coordsystem has its origin at the center of the upper-left pixel of an image. As far as i know it does not depend on the precision, also working with subPixel coords, the coord system has its origin at the center of that upper-left pixel (correct me if I'm wrong).

So my question is: If I have a look at the image at Rect_<int>(0, 0, 1, 1), then it contains the upper left pixel because "OpenCV assumes that the top and left boundary of the rectangle are inclusive, while the right and bottom boundaries are not" (https://docs.opencv.org/3.1.0/d2/d44/...). In Contrast, if I have a look at the image with sub pixel precision at Rect_<float>(0, 0, 1, 1), which pixel lay inside the rect then? From what I understand, the rect would have its center between pixel 0 and 1 at (0.5, 0.5), so the rectangle would contain a quarter of each of the four adjacent pixels.</float></int>

So am I correct in assuming that it is necessary to shift a sub pixel precision float rectangle by (-0.5, -0.5) to obtain the identical part of image like with a Rect of type int ?

Greetings

edit retag flag offensive close merge delete