<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/165841</link>
    <title>MATLAB Central Newsreader - HELP reading JPG and plotting image in 3D</title>
    <description>Feed for thread: HELP reading JPG and plotting image in 3D</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2008 by The MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>The MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Mon, 17 Mar 2008 20:31:30 -0400</pubDate>
      <title>HELP reading JPG and plotting image in 3D</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/165841#421357</link>
      <author>Skip Albertson</author>
      <description>Can anyone tell me the best way to read an image:&lt;br&gt;
&lt;br&gt;
A=imread('pic.jpg');&lt;br&gt;
&lt;br&gt;
and then plot it in a 3D space specifying the vertices.&lt;br&gt;
&lt;br&gt;
If my workspace has x:0-100, y:0-100, and z:0-100 and I want to paste my &lt;br&gt;
JPEG image so that the corners are placed at:&lt;br&gt;
&lt;br&gt;
lower left: x=25, y=25, z=0&lt;br&gt;
upper left: x=25, y=25, z=100&lt;br&gt;
upper right: x=75, y=75, z=100&lt;br&gt;
lower right: x=75, y=75, z=0&lt;br&gt;
&lt;br&gt;
view(3)&lt;br&gt;
&lt;br&gt;
How would I best do that?&lt;br&gt;
&lt;br&gt;
Thanks!&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Tue, 18 Mar 2008 12:08:01 -0400</pubDate>
      <title>Re: HELP reading JPG and plotting image in 3D</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/165841#421465</link>
      <author>Hui Song</author>
      <description>Skip Albertson &amp;lt;alberts@ocean.washington.edu&amp;gt; wrote in &lt;br&gt;
message &lt;br&gt;
&amp;lt;Pine.LNX.4.64.0803171321000.23534@tsunami.ocean.washington.edu&amp;gt;...&lt;br&gt;
&amp;gt; Can anyone tell me the best way to read an image:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; A=imread('pic.jpg');&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; and then plot it in a 3D space specifying the vertices.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; If my workspace has x:0-100, y:0-100, and z:0-100 and I &lt;br&gt;
want to paste my &lt;br&gt;
&amp;gt; JPEG image so that the corners are placed at:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; lower left: x=25, y=25, z=0&lt;br&gt;
&amp;gt; upper left: x=25, y=25, z=100&lt;br&gt;
&amp;gt; upper right: x=75, y=75, z=100&lt;br&gt;
&amp;gt; lower right: x=75, y=75, z=0&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; view(3)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; How would I best do that?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks!&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
Hi John,&lt;br&gt;
Not easy. Try this:&lt;br&gt;
vertice1 = [25 25 0]; % start vertice&lt;br&gt;
vertice2 = [75 75 100] ; % end vertice&lt;br&gt;
imHeight = vertice2(3) - vertice1(3) ; % height&lt;br&gt;
imWidth = norm(vertice1(1:2)-vertice2(1:2)) ; % width&lt;br&gt;
x = linspace(vertice1(1), vertice2(1), imWidth) ;&lt;br&gt;
X = repmat(x, imHeight, 1) ; % create plane mesh&lt;br&gt;
y = linspace(vertice1(2), vertice2(2), imWidth) ;&lt;br&gt;
Y = repmat(y, imHeight, 1) ; % create plane mesh&lt;br&gt;
z = linspace(vertice1(2), vertice2(2), imHeight) ;&lt;br&gt;
Z = repmat(z', 1, imWidth) ; % create plane mesh&lt;br&gt;
[C, map] = imread('canoe.tif') ; % read image&lt;br&gt;
h = surface(X, Y, Z) ; % create a surace&lt;br&gt;
set(h, 'CData', flipud(C), 'FaceColor','texturemap', &lt;br&gt;
'EdgeColor','none','CDataMapping','direct') ; % image as&lt;br&gt;
colormap(map) ;&lt;br&gt;
view(30, 30) ;&lt;br&gt;
</description>
    </item>
    <item>
      <pubDate>Tue, 18 Mar 2008 12:34:01 -0400</pubDate>
      <title>Re: HELP reading JPG and plotting image in 3D</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/165841#421468</link>
      <author>Vihang Patil</author>
      <description>Skip Albertson &amp;lt;alberts@ocean.washington.edu&amp;gt; wrote in &lt;br&gt;
message &lt;br&gt;
&amp;lt;Pine.LNX.4.64.0803171321000.23534@tsunami.ocean.washington&lt;br&gt;
.edu&amp;gt;...&lt;br&gt;
&amp;gt; Can anyone tell me the best way to read an image:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; A=imread('pic.jpg');&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; and then plot it in a 3D space specifying the vertices.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; If my workspace has x:0-100, y:0-100, and z:0-100 and I &lt;br&gt;
want to paste my &lt;br&gt;
&amp;gt; JPEG image so that the corners are placed at:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; lower left: x=25, y=25, z=0&lt;br&gt;
&amp;gt; upper left: x=25, y=25, z=100&lt;br&gt;
&amp;gt; upper right: x=75, y=75, z=100&lt;br&gt;
&amp;gt; lower right: x=75, y=75, z=0&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; view(3)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; How would I best do that?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks!&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
Try this&lt;br&gt;
&lt;br&gt;
load clown&lt;br&gt;
C = X;&lt;br&gt;
X = [0 0; 1 1];&lt;br&gt;
Y = [1 1; 1 1];&lt;br&gt;
Z = [0 1; 0 1];&lt;br&gt;
surface(X,Y,Z,rot90(flipud&lt;br&gt;
(C)),'FaceColor','texturemap','EdgeColor','none','CDataMapp&lt;br&gt;
ing','direct')&lt;br&gt;
view(3)&lt;br&gt;
colormap(map)&lt;br&gt;
cameratoolbar&lt;br&gt;
set(gcf,'color','k');&lt;br&gt;
axis off;&lt;br&gt;
axis vis3d;&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
HTH&lt;br&gt;
Vihang&lt;br&gt;
</description>
    </item>
  </channel>
</rss>
