How to add a picture in the 3D-plane

33 views (last 30 days)
Sijie Cheng
Sijie Cheng on 24 Apr 2019
Answered: Walter Roberson on 24 Apr 2019
The thing is that:
a. I have a picture "hello.jpg"
hello.jpg
b. I have made a code.
clear
I = imread('hello.jpg');
image([0 100],[20 30],I);
hold on
plot3([0 100 100 0 0],[20 20 30 30 20],[0 0 0 0 0],'k');
axis([0 100 0 50 -1 1]);
axis on
grid on
view(19,46);
hold off
c. The figure like that
1.png
The problem is that:
I wanna get two figures below.
2.png
3.png
I have tried many functions to achieve it. However, it is not work.
Do you guys have any good idea?
Thank you.

Answers (2)

Matt J
Matt J on 24 Apr 2019

Walter Roberson
Walter Roberson on 24 Apr 2019
warp() is the most straight-forward way of displaying an image on an arbitrary surface. surf() and patch() can do the work if you know how to set up texture mapping on them (warp() sets up texture mapping automatically.)
There are alternatives, including creating an hgtransform() and using it to parent an image() or imagesc() or imshow(), and then setting the transform matrix of that image object. However, image objects are 2D objects, and if you tilt them even just a little outside the plane then they disappear because they are considered indefinitely thin.

Products

Community Treasure Hunt

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

Start Hunting!