I'm trying to stack 2D images to get 3D just like How can I plot several 2D image in a stack style in Matlab?
my original code had some errors and someone suggested to go with the below code
M = zeros(25, 50, 8);
for k = 1:8
img = imread(sprintf('%d-0000.jpg', k + 30));
img = imresize(img, [25 50]);
img = im2double(rgb2gray(img)); % Convert to double format
M(:, :, k) = img;
end
hf2 = figure ;
hs = slice(M,[],[],1:8) ;
shading interp
set(hs,'FaceAlpha',0.8);
this is the expected result How can I plot several 2D image in a stack style in Matlab?
this is the error I get
Error using rgb2gray>parse_inputs (line 81)
MAP must be a m x 3 array.Error in rgb2gray (line 35)
X = parse_inputs(varargin{:});Error in stack2 (line 9)
img = im2double(rgb2gray(img)); % Convert to double format

ind2gray. It shows you how to get two values out ofimreadand put them intoind2gray. mathworks.com/help/images/ref/ind2gray.html#d117e180249 - Cris Luengo