1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| clear all; % clears all variables
close all; % close all windows
clc ; % clears the command window
[FileName,PathName]= uigetfile({'*.dcm;*.jpg;*.raw;*.RAW;*.img;*.gif;*.bmp;*.jpg'}, ...
'Select the images','MultiSelect', 'on'); %File Selector
img=imread(FileName);
n=input('saisir la valeur de n =');
A = ones(size(img,1),size(img,2),n); %Matrix shouted there 3D
for i=1:size(img,1)
for j=1:size(img,2)
A(i,j,1:n) = img(i,j);
end;
end;
% Modelling of the domain [x0, x1] ◊ [y0, y1]
[X,Y] = meshgrid(1:size(A,2), 1:size(A,1));
Z = ones(size(A,1),size(A,2));
%# plot each slice as a texture-mapped surface (stacked along the Z-dimension)
for k=1:size(A,3)
surface('XData',X, 'YData',Y, 'ZData',Z.*k, ...
'CData',A(:,:,k), 'CDataMapping','direct', ...
'EdgeColor','none', 'FaceColor','texturemap')
end;
view(3);
% Define title and labels for reference
colormap(gray(256));title('Rotation of a cube 3D...');box on; axis tight square
xlabel('x'),ylabel('y'),zlabel('z');set(gca, 'ZDir','reverse') |
Partager