# Theory behind "center" of top-left pixel considered as (0, 0)

Hello,

I learnt from "resize bi-linear" implementation that the "center" of the (left top) pixel is considered as "origin" (0, 0). It appears that if "top left corner" were considered as origin then it would have actually simplified the equations. But as this is not done, there must be some theoretical reason behind choosing center as origin. I got one hint from below comment on http://answers.opencv.org/question/87... by @StevenPuttemans: "origin is at the center of the top-left pixel, because else there would be an imbalance in coordinate systems with negative valued axes ..."

But unfortunately I'm unable to fully grasp it with above hint. Could Steven or anybody else provide some more theoretical details for clearing the concept...

edit retag close merge delete

Sort by » oldest newest most voted

It's easier to understand the concept if you are also thinking about the other pixels.

Let's take a 2x2 pixel image. If (0,0) is the top-left corner of the first pixel, then the pixel center coordinate is (0.5,0.5). This means that the coordinate (1,1) (normally the center of a pixel) would correspond to a boundary between 4 pixels, which makes no sense.

If (0,0) is the center of the first pixel, then (0.5,0.5) is "half-way" between the pixels, which is much more logical.

Maybe it's easier to imagine if you resize the image by a factor of 10. You would find the first pixel at the strange position (5,5), the second pixel at (15,5).

If we generalize, for a resize factor K, you'll find pixel (x,y) at the coordinates (K(x+0.5),K(y+0.5)) instead of the much simpler (Kx,Ky)

more

Hi Barna,

Thanks for the answer. I have one correction. For resize factor of k, the translated coordinates are (Kx, Ky) if we consider top left corner of the pixel as (0, 0). This will map (0, 0) in input image to (0, 0) in scaled image. For center of the pixel as (0, 0) i.e. top left cood (-0.5, -0.5), the input (x, y) will map to (K(x+0.5), K(y+0.5)) in the scaled image.

I also found an intuitive explanation that in camera/display, the light sensing/emitting element must be placed at the center of the square pixel as light propagates in all directions.

I's specifically interested in Steven Puttemans comment that if the origin is not at the center of the pix, there would be an imbalance in coordinate systems with negative valued axes. I'd appreciate any ...(more)

( 2019-03-05 07:22:03 -0500 )edit

Official site

GitHub

Wiki

Documentation