MATLAB: 3d Plot “pile up 100 2d images” in 3d plane

2d3d3d plotsimageimage processingMATLABmatrixmatrix arraymatrix manipulationplaneplot

3d PLOT 100 2d images pile up one above other MATLAB
I have 100 matrixes each with order 360*360
i.e a(1) to a(100)
%a(1)=360×360
K = mat2gray(a(1))
imagesc(K) #PLOTTED a 2d image
What I want is to pile up all 100 images on top of each other in 3d plot
My attempt
I thought adding a third axis to matrix would work with z as 1,2,…100 [say hieght]
like a(1,1,i)=i to a(360,360,i)=i //where i is height in z axis so at each z one 2d image
for i = 1:100
l = data(:,i);
a100(:,:,i) = reshape(l, 360, []);
end
finally I have a1=360x360x100 now I want to plot them all

Best Answer

You can use the function slice (see the help and documentation for details), but to do that you'll have to use 3-D arrays as input - that is you'll have to put your individual images into a 3-D array, something like this:
Iall3D(:,:,100) = a100; % it is not entirely clear what data-type your a is
... etc
Then you can use slice:
x = 1:size(Iall3D,2);
y = 1:size(Iall3D,1);
z = 1:size(Iall3D,3);
slice(x,y,z,Iall3D,[],[],1:10:100),shading flat
Or you can use the surf function and display the images manually:
[X,Y] = meshgrid(x,y);
Z = 1:100;
for iZ = 1:numel(Z),
surf(X,Y,Z(iZ)*ones(size(X)),Iall3D(:,:,iZ)),shading flat
hold on
end
You will have some significant problems with closely overlapping slices hiding the layers behind, but that's something you'll have to adjust to suit your needs and data. Sometimes is is possible to get somewhere using the transparency properties of the surfaces to make them slightly transparent (that should be the "alpha***" properties, for using this you'll have to call surf with an output to get the handle to the surfaces, and then get and set to modify these properties.)
HTH