how to put the image that is sky background in the 3D axes in plot

please help me with 'how to put the image of sky to background of 3D axis, in the graph what i have plotted'.

2 commentaires

How should the image move when you change the viewpoint?
Is it necessary that the image be part of the same 3D axis, or could it be a different axis that is visually "behind" the 3D axis?
Or, do you just want a sky blue background to the plot instead of the default white?

Connectez-vous pour commenter.

Réponses (1)

You can show an image in 3D using surf
I = imread('cameraman.tif');
[X Y] = meshgrid(1:size(I,1), fliplr(1:size(I,2)));
surf(X, ones(size(I)), Y, I,'EdgeColor','none')
or
surf(X, Y, ones(size(I)), I,'EdgeColor','none')
or
surf(ones(size(I)), X, Y, I,'EdgeColor','none')

1 commentaire

Yes, you can use surf like this. It's a bit more efficient to do something like this though:
I = imread('cameraman.tif');
z_off = -10;
X = [1 size(I,2)];
Y = [size(I,1) 1];
Z = z_off + zeros(2);
surf(X,Y,Z,I,'FaceColor','texture','EdgeColor','none')
That results in a surface which only has 4 vertices, rather than one with 1 vertex for each pixel, which is what you get if you make X,Y, & Z the same size as I.
Also, starting in R2014b, you can use image in 3D. The tricky bit is that the image object doesn't have Z coordinates. But you can use hgtransform to move it to the location you'd like.
g = hgtransform;
image(I,'Parent',g)
axis ij
g.Matrix = makehgtform('translate',[0 0 z_off]);

Connectez-vous pour commenter.

Catégories

En savoir plus sur Object Containers dans Centre d'aide et File Exchange

Question posée :

le 30 Nov 2015

Commenté :

le 30 Nov 2015

Community Treasure Hunt

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

Start Hunting!

Translated by