38 lines
1.1 KiB
Mathematica
38 lines
1.1 KiB
Mathematica
|
function affichage_nuage(masque,K,z,I)
|
||
|
|
||
|
% Dimensions du masque :
|
||
|
[nb_lignes,nb_colonnes] = size(masque);
|
||
|
nb_pixels = nb_lignes*nb_colonnes;
|
||
|
|
||
|
% Indices des pixels du masque :
|
||
|
ind_masque = transpose(find(masque>0));
|
||
|
[i_masque,j_masque] = ind2sub(size(masque),ind_masque);
|
||
|
|
||
|
% Passage du repère pixels au repère image :
|
||
|
u_masque = j_masque;
|
||
|
v_masque = i_masque;
|
||
|
p_tilde = [ u_masque ; v_masque ; ones(1,length(ind_masque)) ];
|
||
|
w = inv(K)*p_tilde;
|
||
|
|
||
|
% Lissage médian de la fonction de profondeur :
|
||
|
z_image = zeros(nb_pixels,1);
|
||
|
z_image(ind_masque) = z;
|
||
|
z_image = reshape(z_image,nb_lignes,nb_colonnes);
|
||
|
z_image_lissee = medfilt2(z_image,[3 3]);
|
||
|
z_lissee = z_image_lissee(ind_masque);
|
||
|
z_lissee = z_lissee(:);
|
||
|
|
||
|
% Calcul des points 3D :
|
||
|
Q = NaN*ones(nb_pixels,3);
|
||
|
Q(ind_masque,:) = w'.*repmat(z_lissee,1,3);
|
||
|
Q = reshape(Q,[nb_lignes nb_colonnes 3]);
|
||
|
|
||
|
% Affichage des points 3D coloriés par l'image de référence :
|
||
|
couleurs_3D = reshape(uint8(255*I),[nb_pixels,3]);
|
||
|
nuage_points_3D = pointCloud(reshape(Q,[nb_pixels,3]),'Color',couleurs_3D);
|
||
|
pcshow(nuage_points_3D,'VerticalAxis','y','VerticalAxisDir','down','MarkerSize',45);
|
||
|
axis equal;
|
||
|
axis off;
|
||
|
rotate3d;
|
||
|
zoom(1.6);
|