Stacking indexed images and view the resulting volume

2 ビュー (過去 30 日間)
Anand P
Anand P 2019 年 6 月 10 日
回答済み: Subhadeep Koley 2021 年 4 月 8 日
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?

回答 (1 件)

Subhadeep Koley
Subhadeep Koley 2021 年 4 月 8 日
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!

Translated by