How to display an image in 3D cordinate axes ?

8 Ansichten (letzte 30 Tage)
Shivani Limaye
Shivani Limaye am 12 Jul. 2021
Kommentiert: ANKUR KUMAR am 13 Jul. 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.

Antworten (1)

ANKUR KUMAR
ANKUR KUMAR am 13 Jul. 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 Kommentare
Shivani Limaye
Shivani Limaye am 13 Jul. 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 am 13 Jul. 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,:))

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Communications Toolbox finden Sie in Help Center und File Exchange

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by