3D reconstruction from a 2D image
17 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Damon Pierre-Marie
le 9 Nov 2017
Commenté : Ayush singhal
le 22 Mai 2021
Hello,
I have some difficulties to reconstruct a 3D scene from a 2D image. I would like to create a top view of scene removing the perspective, in other words, realize an inverse perspective mapping. Let's assume we know the camera position, orientation and its parameters. Moreover we consider all the captured points lie on the same plane XY. Then, it is easy to prove that a pixel at a (u,v) location in the image will move to the coordinate (X,Y,0) in the 3D space with:
X=-((u*P(3,4)-P(1,4))*(v*P(3,1)-P(2,1)) + (v*P(3,4)-P(2,4))*(P(1,1)-u*P(3,1)))/((u*P(3,2)-P(1,2))*(v*P(3,1)-P(2,1)) + (v*P(3,2)-P(2,2))*(P(1,1)-u*P(3,1)));
Y=(X*(u*P(3,2)-P(1,2)) + (u*P(3,4)-P(1,4)))/(P(1,1)-u*P(3,1));
P is the projection matrix such that: P=[KR KT] with K,R and T respectively the intrinsic, rotation and translation matrices.
Once all the 3D locations of each pixel are computed, I would like to display the XY plane with the color information of the original pixel as if it was a 2D image.
However, a pixel (u,v) can mapped in 3D space to a non integer location meaning that I get a non-regular scatter plot were each (X,Y) point contain a color information. I tried to divide the XY plane into small windows and then compute the average color of all points into each squares but it is very slow.
Please find my code enclosed. Some help would be appreciated!
Thank you in advance, Pm
8 commentaires
mostafa TAIBI
le 13 Fév 2020
another question if you allow, for the 3d reconstruction is that you take all the pixels of the image after you use the formula to calculate X and Y?
Réponse acceptée
Matt J
le 9 Nov 2017
Modifié(e) : Matt J
le 9 Nov 2017
Once all the 3D locations of each pixel are computed, I would like to display the XY plane with the color information of the original pixel as if it was a 2D image.
I don't think you need to be doing the work of mapping and interpolating the coordinates. I think it should be as simple as
Image2 = imwarp(Image1,projective2d(P(:,[1,2,4]).'))
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Computer Vision with Simulink dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



