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

12 views (last 30 days)
please help me with 'how to put the image of sky to background of 3D axis, in the graph what i have plotted'.
  2 Comments
Walter Roberson
Walter Roberson on 30 Nov 2015
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?
Image Analyst
Image Analyst on 30 Nov 2015
Or, do you just want a sky blue background to the plot instead of the default white?

Sign in to comment.

Answers (1)

Thorsten
Thorsten on 30 Nov 2015
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 Comment
Mike Garrity
Mike Garrity on 30 Nov 2015
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]);

Sign in to comment.

Categories

Find more on Specifying Target for Graphics Output in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!