32 lines
741 B
Mathematica
32 lines
741 B
Mathematica
|
function affichage_surface(masque,K,z)
|
||
|
|
||
|
% 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;
|
||
|
|
||
|
% Calcul des points 3D :
|
||
|
Q = NaN*ones(nb_pixels,3);
|
||
|
Q(ind_masque,:) = w'.*repmat(z,1,3);
|
||
|
Q = reshape(Q,[nb_lignes nb_colonnes 3]);
|
||
|
|
||
|
% Affichage des points 3D :
|
||
|
surfl(Q(:,:,1),Q(:,:,2),-Q(:,:,3),[0 90]);
|
||
|
shading flat;
|
||
|
colormap gray;
|
||
|
axis ij;
|
||
|
axis tight;
|
||
|
axis equal;
|
||
|
axis off;
|
||
|
rotate3d;
|
||
|
zoom(1.4);
|