How to display an image in 3D cordinate axes ?
8 次查看(过去 30 天)
显示 更早的评论
I want to display this image in 3D cordinate system with x,y and z axes. Pls. help me out.
Attached below is the image in question. It is a 3D image 780x1040x3 size.
0 个评论
回答(1 个)
ANKUR KUMAR
2021-7-13
It is not really a 3D image. The third dimension has the RGB values. That is why you can able to see the color image.
Let's see this example.
A=imread('peppers.png');
size(A)
A is a 3D matrix, but RGB values are stored along the third dimension.
imshow(A)
If you plot using only the X and Y coordinate, you would get like this in each of the third dimension.
imshow(A(:,:,1))
imshow(A(:,:,2))
imshow(A(:,:,3))
The combination of these three images results into a color image.
2 个评论
ANKUR KUMAR
2021-7-13
X, Y and Z are just the sequence of numbers from 1 to the size along that dimension.
A=imread('peppers.png');
size(A)
imshow(A)
These would be your coordinates of image.
X=[1:size(A,1)];
Y=[1:size(A,2)];
Z=[1:size(A,3)];
Above are the X, Y and Z coordinates of the image. You can plot it using contourf function giving corrdinates as arguments.
figure
for index=1:3
subplot(2,2,index)
contourf(Y,X,A(:,:,index),'linecolor','none')
set(gca,'Ydir','rev')
daspect(ones(1,3))
title(index)
end
If you want to crop the image, you can use these dimension to crop it, followed by using imshow or contourf as per your need.
figure
for index=1:3
subplot(2,2,index)
contourf(Y(400:510),X(200:325),A(200:325,400:510,index),'linecolor','none')
set(gca,'Ydir','rev')
daspect(ones(1,3))
title(index)
end
subplot(2,2,4)
imshow(A(200:325,400:510,:))
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Communications Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!