How to display an image in 3D cordinate axes ?

8 ビュー (過去 30 日間)
Shivani Limaye
Shivani Limaye 2021 年 7 月 12 日
コメント済み: ANKUR KUMAR 2021 年 7 月 13 日
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.

回答 (1 件)

ANKUR KUMAR
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)
ans = 1×3
384 512 3
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 件のコメント
Shivani Limaye
Shivani Limaye 2021 年 7 月 13 日
Oh okay. Then will it take a video feed to have 3D ?
Also, how can I get the X,Y & Z cordinates of all points in the image.
ANKUR KUMAR
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)
ans = 1×3
384 512 3
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 ExchangeConvert Image Type についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by