How to display an image in 3D cordinate axes ?

8 vues (au cours des 30 derniers jours)
Shivani Limaye
Shivani Limaye le 12 Juil 2021
Commenté : ANKUR KUMAR le 13 Juil 2021
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.

Réponses (1)

ANKUR KUMAR
ANKUR KUMAR le 13 Juil 2021
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 commentaires
Shivani Limaye
Shivani Limaye le 13 Juil 2021
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 le 13 Juil 2021
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,:))

Connectez-vous pour commenter.

Catégories

En savoir plus sur Communications Toolbox dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by