Stacking indexed images and view the resulting volume

2 views (last 30 days)
I have used the following code to convert RGB images to indexed image and stack them as a cube
A =imread('image2.png'); %A is a RGB image
B =imread('image3.png'); %B is a RGB image
C =imread('image4.png'); %C is a RGB image
[D,map] = rgb2ind(A,256); %D is an indexed image
E = rgb2ind(B,map); %D is an indexed image
F = rgb2ind(C,map); %D is an indexed image
G = zeros(size(A,1),size(A,2),3) %%G is my volume here
%%Note that A,B and C have the same dimensions. Similarly D,E and F have the same dimensions
G(:,:,1)=D;
G(:,:,2)=E;
G(:,:,3)=F;
The indexed image is viewed using the code
figure
imagesc(E)
colormap(map)
In a similar manner, how can I view my cube G using the same colormap?

Answers (1)

Subhadeep Koley
Subhadeep Koley on 8 Apr 2021
This code snippet might help.
A = imread('image2.png');
B = imread('image3.png');
C = imread('image4.png');
[D, map] = rgb2ind(A, 256);
E = rgb2ind(B, map);
F = rgb2ind(C, map);
G = cat(3, D, E, F);
figure
volshow(G, 'Colormap', map);

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!