pointstoworld() function error

I calibrated my camera then I wanted to measure the distance from the camera as given in the toolbox documentation which all went fine.
Now when I wanted to use the top left point in the image as a reference for further, I wanted to know its poistion in real world. How come I do not get an error when I set my imagePoints to [0 0] ? The image indexing starts with ones not zeros as far as I know ?
Or the imagePoints here do not refer to the coordinates of the point in the image ?

8 Comments

Are you asking why you get or why you dont get an error?
"How come I do not get an error when I set my imagePoints to [0 0] ? " Because image points start at X0 Y0, thats why. In image processing, when you have a 800x600 image your image index goes from 0 to 799 and 0 to 599.
Hesham Khalifa
Hesham Khalifa on 30 Jul 2018
Edited: Hesham Khalifa on 30 Jul 2018
image= imread('cameraman.tif')
now image is 2D matrix where the indexing starts from 1 to 256.
If i try to access the top left point of the image I would type image(1,1) not image(0,0) or Do I understand all wrong ?
If you take a look at the example section, you can see that the worldPoints start at [0 0] and if you set your imagePoints to worldPoints, those also start at [0 0]
my world point [0 0] is the top left corner of the checkerboard. These are mapped by the imagePoints. The images points are the pixel locations where the checkerboard corners detected in the 2D image. for Example worldPoint [0 0] corresponds to image point [475 571] ( this is the pixel location of this world point in the image). So, it is still confusing for me how you can put [0 0] for the ''image'' as I referred in my previous comment
Florian Morsch
Florian Morsch on 31 Jul 2018
Edited: Florian Morsch on 31 Jul 2018
Because pixels are always couted from X0 Y0. As i said in a previous comment, if you have a image with a resolution of 800x600 pixel, your start at pixel 0,0 and end at 799,599. The top left pixel is always 0,0 and you start to count your pixels coordinates from there.
In the case of the cameraman.tif, you have a picture with 256x256 pixels. This means you have 256 rows of pixel and 256 collums of pixel. The counting of those pixels however starts with index X0 Y0 and ends with X255 Y255. So the pixel at row 1, collumn 1 (top left pixel) has the pixel coordinate X0 Y0. The pixel at row 256, collumn 256 has the pixel coordinate X255 Y255.
or google "pixel coordinate system". Dont confuse the image size with pixel coordinates, they are not the same.
Thanks. but just to make sure that I got you right in case of the camrea man example my pixel coordinate X0 Y0 corresponds to image(1,1) right ?
I think my mistake was I treated the pixel coordinate system is the same as the image as a matrix
Yes, you are correct there. The pixel coordinate 0 0 refers to the matrix element (1, 1).

Sign in to comment.

Answers (0)

Asked:

on 28 Jun 2018

Commented:

on 31 Jul 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!