For anyone else wondering, (x, y) is the upper-left corner here.
egbenedict
It seems to me as if many (if not most) graphics systems/interfaces place the origin in the upper-left corner. Is there a practical reason for this, or is it purely some convention started ages ago (I imagine maybe as a byproduct of the raster scan on CRT monitors starting from that corner)?
Staffjamesfong1
@egbenedict At this point it is just convention. It may have originated with western text-only displays. On those displays, it would have been natural to make the origin in the top-left corner, which is where you start reading.
We are fortunate that nearly everyone agrees on this convention for 2D displays. If we did not agree, software written for a top-left origin might show its images upside-down when put on a bottom-right monitor!
Staffyirenng
@egbenedict Yes, just a convention, and different graphics systems make different choices. Not always easy to find the specification! This is a common source of bugs.
For example, can anyone find the spec defining the screen coordinate frame convention used in OpenGL?
justin-shao
@yirenng
I found this documentation on Mouse_Trackball object (wiki link), where it mentions that OpenGL's default screenspace origin is the bottom-left corner.
bennyd87708
Is including the shift to the center of each pixel by sampling at the coordinate +0.5 on both x and y something that is actually important to do for the correct output? Intuitively, I would think that just sampling at the top left corner of each pixel would result in practically the same result (just potentially shifted by half a pixel in each direction when the sampled value is displayed on each pixel) with the potential benefit of simpler math/code from not having to worry about the extra 0.5 like is shown on the previous slide.
Staffjamesfobrien
The key thing to keep in mind is that a computational pixel is not a single point, it is a 2D shape with area, nearly always a square or sometimes a rectangle. (And the computational pixel is distinct from the thing that lights up on your screen.)
Staffethanweber
@bennyd87708 Here's an article by Alvy Ray Smith describing how a pixel is a sample. It talks about misconceptions about pixels too. Could be interesting to take a look at!
Staffjamesfobrien
The article by Alvy is great, but the word pixel is used for a lot of different-yet-related things. I disagree with conflating a pixel and a sample.
alliu879
@ethanweber I also found the definition of a pixel to be confusing here, but found the Smith article to be quite helpful in understanding this!
Staffatsu-kotani
As you all might imagine, this problem is not unique to computer graphics but becomes quite important in general applications. For instance, a function in PyTorch (deep learning library) called grid_sample is a popular function, which samples points in a grid, but the locations of those sampling locations change by how you define the pixel (either by a grid of a point). Here is another visualization.
For anyone else wondering,
(x, y)
is the upper-left corner here.It seems to me as if many (if not most) graphics systems/interfaces place the origin in the upper-left corner. Is there a practical reason for this, or is it purely some convention started ages ago (I imagine maybe as a byproduct of the raster scan on CRT monitors starting from that corner)?
@egbenedict At this point it is just convention. It may have originated with western text-only displays. On those displays, it would have been natural to make the origin in the top-left corner, which is where you start reading.
We are fortunate that nearly everyone agrees on this convention for 2D displays. If we did not agree, software written for a top-left origin might show its images upside-down when put on a bottom-right monitor!
@egbenedict Yes, just a convention, and different graphics systems make different choices. Not always easy to find the specification! This is a common source of bugs.
For example, can anyone find the spec defining the screen coordinate frame convention used in OpenGL?
@yirenng
I found this documentation on Mouse_Trackball object (wiki link), where it mentions that OpenGL's default screenspace origin is the bottom-left corner.
Is including the shift to the center of each pixel by sampling at the coordinate +0.5 on both x and y something that is actually important to do for the correct output? Intuitively, I would think that just sampling at the top left corner of each pixel would result in practically the same result (just potentially shifted by half a pixel in each direction when the sampled value is displayed on each pixel) with the potential benefit of simpler math/code from not having to worry about the extra 0.5 like is shown on the previous slide.
The key thing to keep in mind is that a computational pixel is not a single point, it is a 2D shape with area, nearly always a square or sometimes a rectangle. (And the computational pixel is distinct from the thing that lights up on your screen.)
@bennyd87708 Here's an article by Alvy Ray Smith describing how a pixel is a sample. It talks about misconceptions about pixels too. Could be interesting to take a look at!
The article by Alvy is great, but the word pixel is used for a lot of different-yet-related things. I disagree with conflating a pixel and a sample.
@ethanweber I also found the definition of a pixel to be confusing here, but found the Smith article to be quite helpful in understanding this!
As you all might imagine, this problem is not unique to computer graphics but becomes quite important in general applications. For instance, a function in PyTorch (deep learning library) called grid_sample is a popular function, which samples points in a grid, but the locations of those sampling locations change by how you define the pixel (either by a grid of a point). Here is another visualization.