0
$\begingroup$

This is related to this question: What is blender's camera projection matrix model?

In the answer of this question, it is stated that the center coordinate of the blender camera is given by

u_0 = resolution_x_in_px*scale / 2 (=width/2)
v_0 = resolution_y_in_px*scale / 2 (=height/2)

I am not really sure if I interpret this correctly. If the raw coordinates of the image are given 0-based (i.e., x in [0,...,width-1] and y in [0,...,height-1]), this definition would lead to an asymmetric camera center. A symmetric camera center would be given by

u_0 = width/2 - 0.5
v_0 = height/2 - 0.5

I have tried to test this with a simple scene consisting of two black planes touching exactly at the camera center. I rendered two 16x16 image of that scene, one with an unrotated camera and one with a 180° rotated camera. The expectation is that the second image can also be generated by flipping the first image in both dimensions. This is the output:

image1 =
  [[255, 255, 255, 255, 255, 255, 255, 253, 243, 241, 241, 241, 241, 241, 243, 253],
   [255, 255, 255, 255, 255, 255, 255, 243, 130,  97,  97,  97,  97,  97, 130, 243],
   [255, 255, 255, 255, 255, 255, 255, 241,  97,   0,   0,   0,   0,   1,  97, 241],
   [255, 255, 255, 255, 255, 255, 255, 241,  97,   0,   0,   0,   1,   0,  97, 241],
   [255, 255, 255, 255, 255, 255, 255, 241,  97,   0,   0,   1,   0,   0,  97, 241],
   [255, 255, 255, 255, 255, 255, 255, 241,  96,   0,   0,   0,   0,   0,  97, 241],
   [255, 255, 255, 255, 255, 255, 255, 241,  96,   1,   0,   0,   0,   0,  97, 241],
   [253, 243, 241, 241, 241, 241, 241, 230, 127,  96,  97,  97,  97,  97, 130, 243],
   [243, 130,  97,  97,  97,  97,  97, 125, 230, 241, 241, 241, 241, 241, 243, 253],
   [241,  97,   0,   0,   0,   0,   1,  97, 241, 255, 255, 255, 255, 255, 255, 255],
   [241,  97,   0,   0,   0,   1,   0,  97, 241, 255, 255, 255, 255, 255, 255, 255],
   [241,  97,   0,   0,   0,   0,   0,  97, 241, 255, 255, 255, 255, 255, 255, 255],
   [241,  97,   0,   1,   0,   0,   0,  97, 241, 255, 255, 255, 255, 255, 255, 255],
   [241,  97,   0,   0,   0,   0,   0,  97, 241, 255, 255, 255, 255, 255, 255, 255],
   [243, 130,  97,  96,  97,  97,  97, 130, 243, 255, 255, 255, 255, 255, 255, 255],
   [254, 243, 241, 241, 241, 241, 241, 243, 254, 255, 255, 255, 255, 255, 255, 255]]

image2 =
  [[255, 255, 255, 255, 255, 255, 255, 253, 243, 241, 241, 241, 241, 241, 243, 253],
   [255, 255, 255, 255, 255, 255, 255, 243, 130,  97,  97,  97,  97,  97, 130, 243],
   [255, 255, 255, 255, 255, 255, 255, 241,  97,   0,   0,   0,   0,   0,  97, 241],
   [255, 255, 255, 255, 255, 255, 255, 241,  97,   0,   0,   0,   0,   0,  97, 241],
   [255, 255, 255, 255, 255, 255, 255, 241,  97,   0,   0,   0,   0,   0,  97, 241],
   [255, 255, 255, 255, 255, 255, 255, 241,  96,   0,   0,   0,   0,   0,  97, 241],
   [255, 255, 255, 255, 255, 255, 255, 241,  96,   0,   0,   0,   0,   0,  97, 241],
   [253, 243, 241, 241, 241, 241, 241, 230, 127,  96,  97,  97,  97,  97, 130, 243],
   [243, 130,  97,  97,  97,  97,  97, 125, 230, 241, 241, 241, 241, 241, 243, 253],
   [241,  97,   0,   0,   0,   0,   0,  97, 241, 255, 255, 255, 255, 255, 255, 255],
   [241,  97,   0,   0,   0,   0,   0,  97, 241, 255, 255, 255, 255, 255, 255, 255],
   [241,  97,   0,   0,   0,   0,   0,  97, 241, 255, 255, 255, 255, 255, 255, 255],
   [241,  97,   0,   0,   0,   0,   0,  97, 241, 255, 255, 255, 255, 255, 255, 255],
   [241,  97,   0,   0,   0,   0,   0,  97, 241, 255, 255, 255, 255, 255, 255, 255],
   [243, 130,  97,  96,  97,  97,  97, 130, 243, 255, 255, 255, 255, 255, 255, 255],
   [253, 243, 241, 241, 241, 241, 241, 243, 254, 255, 255, 255, 255, 255, 255, 255]]

As you can see, the expectation is met (almost). Is this the correct interpretation, that the image center is (symmetrically) in the center of the image?

$\endgroup$
  • $\begingroup$ It would be more natural to say that the origin of a pixel is the pixel's center, that's the normal convention for usage in camera matrices (as targeted in the original post). Otherwise you would have to account for the pixel size after the projection / unprojection. With that convention, the original definition is implicitely assuming pixel coordinartes x = [0.5, ... width-0.5] and y = [0.5, ... height-0.5]. Right? $\endgroup$ – wiede Oct 25 '17 at 15:29
  • $\begingroup$ do you agree , pixel(0, 0) will have a corner at uv coordinate (0, 0) not its centre. (pixel_width / 2, pixel_height / 2) The last pixel will be at image coordinate (resx-1, resy-1) and have a corner at u, v coordinate 1, 1. Just can't come at how the centre would be (res - 1) / 2 Even with placing the pixel "origin" at half pixel steps, the first is going to have a corner at uv (0, 0) and the last at uv (1, 1) you've chopped off two half pixels when calculating from centre of first to last. Add them back and guess what you get. $\endgroup$ – batFINGER Oct 25 '17 at 16:28
  • $\begingroup$ I think we are just struggling with different definitions / conventions: In a computer vision context, you usually have an intrinsic matrix K = [[fx,0,u_0],[0,fy,v_0],[0,0,1]], which is essentially used for converting between centralized, normalized pixel coordinates (CNP) and raw pixel coordinates (RP). RP coordinates typically take integer values [0, ..., dim-1] and they are referring to indices in the pixel matrix. CNP coordinates can be interpreted as directions from the projection center through the pixel centers. Using this definition, u_0 and v_0 must be set to (dim/2 - 0.5). $\endgroup$ – wiede Oct 25 '17 at 17:02
  • $\begingroup$ The centre of a 2 x 2 pixel image (or camera) is (0.5, 0.5) or a 3 x 3 (1, 1) no freaken way. That's what your question is saying. An even by even resolution wont have a pixel in the middle of the image no matter how you project it. The center in UV is always (0.5, 0.5) let's hope we can agree on that $\endgroup$ – batFINGER Oct 25 '17 at 17:44
  • $\begingroup$ Sorry, but did you actually read my comment? $\endgroup$ – wiede Oct 25 '17 at 18:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.