Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: HELP reading JPG and plotting image in 3D

Subject: HELP reading JPG and plotting image in 3D

From: Skip Albertson

Date: 17 Mar, 2008 20:31:30

Message: 1 of 3

Can anyone tell me the best way to read an image:

A=imread('pic.jpg');

and then plot it in a 3D space specifying the vertices.

If my workspace has x:0-100, y:0-100, and z:0-100 and I want to paste my
JPEG image so that the corners are placed at:

lower left: x=25, y=25, z=0
upper left: x=25, y=25, z=100
upper right: x=75, y=75, z=100
lower right: x=75, y=75, z=0

view(3)

How would I best do that?

Thanks!


Subject: Re: HELP reading JPG and plotting image in 3D

From: Hui Song

Date: 18 Mar, 2008 12:08:01

Message: 2 of 3

Skip Albertson <alberts@ocean.washington.edu> wrote in
message
<Pine.LNX.4.64.0803171321000.23534@tsunami.ocean.washington.edu>...
> Can anyone tell me the best way to read an image:
>
> A=imread('pic.jpg');
>
> and then plot it in a 3D space specifying the vertices.
>
> If my workspace has x:0-100, y:0-100, and z:0-100 and I
want to paste my
> JPEG image so that the corners are placed at:
>
> lower left: x=25, y=25, z=0
> upper left: x=25, y=25, z=100
> upper right: x=75, y=75, z=100
> lower right: x=75, y=75, z=0
>
> view(3)
>
> How would I best do that?
>
> Thanks!
>
>
Hi John,
Not easy. Try this:
vertice1 = [25 25 0]; % start vertice
vertice2 = [75 75 100] ; % end vertice
imHeight = vertice2(3) - vertice1(3) ; % height
imWidth = norm(vertice1(1:2)-vertice2(1:2)) ; % width
x = linspace(vertice1(1), vertice2(1), imWidth) ;
X = repmat(x, imHeight, 1) ; % create plane mesh
y = linspace(vertice1(2), vertice2(2), imWidth) ;
Y = repmat(y, imHeight, 1) ; % create plane mesh
z = linspace(vertice1(2), vertice2(2), imHeight) ;
Z = repmat(z', 1, imWidth) ; % create plane mesh
[C, map] = imread('canoe.tif') ; % read image
h = surface(X, Y, Z) ; % create a surace
set(h, 'CData', flipud(C), 'FaceColor','texturemap',
'EdgeColor','none','CDataMapping','direct') ; % image as
colormap(map) ;
view(30, 30) ;

Subject: Re: HELP reading JPG and plotting image in 3D

From: Vihang Patil

Date: 18 Mar, 2008 12:34:01

Message: 3 of 3

Skip Albertson <alberts@ocean.washington.edu> wrote in
message
<Pine.LNX.4.64.0803171321000.23534@tsunami.ocean.washington
.edu>...
> Can anyone tell me the best way to read an image:
>
> A=imread('pic.jpg');
>
> and then plot it in a 3D space specifying the vertices.
>
> If my workspace has x:0-100, y:0-100, and z:0-100 and I
want to paste my
> JPEG image so that the corners are placed at:
>
> lower left: x=25, y=25, z=0
> upper left: x=25, y=25, z=100
> upper right: x=75, y=75, z=100
> lower right: x=75, y=75, z=0
>
> view(3)
>
> How would I best do that?
>
> Thanks!
>
>

Try this

load clown
C = X;
X = [0 0; 1 1];
Y = [1 1; 1 1];
Z = [0 1; 0 1];
surface(X,Y,Z,rot90(flipud
(C)),'FaceColor','texturemap','EdgeColor','none','CDataMapp
ing','direct')
view(3)
colormap(map)
cameratoolbar
set(gcf,'color','k');
axis off;
axis vis3d;


HTH
Vihang

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

envelope graphic E-mail this page to a colleague

Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.
Related Topics