Matching pixels in orthomosaic to corresponding pixels in undistorted input images

How can I match pixels in my output orthomosaic to the corresponding pixels in my undistorted input images?

I am aware of the output pmatrix file which can be used to match point cloud vertices to image pixels, can this also be used for the orthomosaic?

I’m trying to work this out following the formula from https://support.pix4d.com/hc/en-us/articles/202977149-What-does-the-Output-Params-Folder-contain-#label12 but I’m hitting a bit of a road block. Presumably I can get the X and Y coordinates of any pixel in the orthomosaic by using the world file (world coordinates + pixel location * pixel size), and the Z coordinate from the DSM, however when I multiply these coordinates by a matrix from the [project]_pmatrix.txt file I get some very large values, so I tried doing the same with the point cloud and got the same results.

Let’s say I pick a point from my cloud in the Pix4D Mapper desktop app: the point coordinates (X, Y, Z) are (612834, 6022815, 334) using WGS84. The app shows me several images which contain this point, and I pick one where the pixel coordinates corresponding to my chosen point are (1499, 1112) in an image of size 4000 x 3000. I take the matrix corresponding to this image and multiply it with the point coordinates to get a new set of coordinates (x,y,z) which gives(14190732177, 4139527026, 723498). Dividing x and y by z gives me a pixel location of (19614, 5799), which is clearly incorrect.

What am I doing wrong? Some of the matrix values look a bit odd, so I’ve copied it below; could this be the culprit? My map is ~650m by ~450m at a resolution of ~3cm.

115.596942   2344.501702 -1828.104356 15491.701779
2434.055636 449.028246   -923.594688   -340498.232885
0.227681       0.097014       -0.968891       -18.233849

 

2 Likes

I also tried to use the pmatrix and it does not seem to work right now. We do not actively support these output files and do not have any ressources to allocate to investigate this issue for the moment. 

You can use the project_name_calibrated_camera_parameters file instead. This one is used by our Cloud team for the 3D inspector and works well for perspective cameras. Hope this is an acceptable workaround!

Hi,  

I am also having the same problem and the proposed workaround does not work for me, I get the same results I am getting with pmatrix. 

I am also selecting the a point from the rayCloud and using its computed position values (in meters WGS84) as the input vector (X,Y,Z).

The result I am getting with both pmatrix and with the longer computation suggested using calibrated_camera_parameters file, are not in the range of pixels location in the image (u,v=(64995.18738050609, -2451.1417401108715)).

How would you suggest to find what goes wrong here?

 

Thanks

Hi,

I have run into exactly the same problem and have lost a fair bit of time trying to resolve the issue. Pix4D must come with a solution to this problem as it is a very important issue. How can you say that you will not support the output files generated with Pix4D when your website itself refers to these files for various purposes.

Agreed, it is a bit rubbish. That’s why I’ve moved over to Photoscan.

Hello all,

We took into consideration your comments and we apologize for any inconvenience caused.
Our Team has further investigated the cause of the issue and it was discovered that a constant shift should be applied to the 3D coordinates that refer to the output coordinate system before using the pmatrix. The offset should be subtracted from the 3D coordinate and it is located in the project_name_offset.xyz file.
For more information check again our updated article.

We encourage you to share your experience on this post, so that the Community can be helped.

Regards,

Thanks, that’s great. I tried processing my data again with the new information and it works perfectly now.

 

When I originally posted I was using a free trial to evaluate whether Pix4D was suitable for my needs, which now has obviously expired. Would it be possible to get another free trial so that I may reevaluate Pix4D now that I know how to properly use the output?

Thanks. It works with the updated information.

Hello all,

I am glad that it works well for you now. Please let us know in case you encounter any further issues.

@Chris: You can ask for a new Trial in the software and a second 10-day Trial version will be added to your account.

Regards,

Hi,

Is there a way to find 3D location (X,Y,Z) of a pixel location given image p-matrix and offset. Just i want to reverse the above process that finding a 3d point location from 2d un-distorted image pixel location.

 

Thank you

Hello Vamsi,

There is no separate output that allows the conversion of the 2D undistorted image coordinates to the 3D location. You could maybe try to use the inverted pmatrix output in order to get these values. 

Regards,