Thread Subject: Show Image in Plane of 3D Axes

Subject: Show Image in Plane of 3D Axes

From: Andrew Zalesky

Date: 8 Sep, 2007 01:39:56

Message: 1 of 5

I wish to display an image in a certain plane of a 3D axes.
For example, in the plane Z=10, in which case the image
appears just as it would with "imagesc" when the 3D axes are
rotated such that the Z-axis is perpendicular to the screen,
but is gradually obscured when the axes are rotated such
that the Z-axis is parallel to the screen.

I then wish to draw a series of lines in the space of the 3D
axes, which may pass through the surface of the image. For
this purpose, I intend to use the "plot3" function.

Any help on displaying an image in a certain plane of a 3D
axes would be much appreciated.

Andrew

Subject: Show Image in Plane of 3D Axes

From: us

Date: 8 Sep, 2007 02:17:58

Message: 2 of 5

Andrew Zalesky:
<SNIP 3d <image> evergreen...

one of the solutions

% some data
% ...the image
     m=load('clown');
     img=flipud(m.X);
% ...the x/y/z
     x=1:size(img,2);
     y=100*ones(size(x));
     z=sind(x);
% the plot
     pimg=zeros(size(img)+[1,1]);
     pimg(1:end-1,1:end-1)=img;
     ph=pcolor(pimg);
     shading flat; % <- or shading interp
     line(x,y,z,...
         'marker','.',...
         'markerfacecolor',[0,0,1],...
         'linestyle','none',...
         'color',[0,0,1]);
     alpha(ph,.8);
     view(30,30);

us

Subject: Show Image in Plane of 3D Axes

From: Andrew Zalesky

Date: 8 Sep, 2007 03:44:30

Message: 3 of 5

I appreciate your solution. This works well.

However, how do I shift the image from the Z = 0 plane to
the plane Z = 10? Or some other plane such as X = 10.

Andrew

"us " <us@neurol.unizh.ch> wrote in message
<fbt0om$4sq$1@fred.mathworks.com>...
> Andrew Zalesky:
> <SNIP 3d <image> evergreen...
>
> one of the solutions
>
> % some data
> % ...the image
> m=load('clown');
> img=flipud(m.X);
> % ...the x/y/z
> x=1:size(img,2);
> y=100*ones(size(x));
> z=sind(x);
> % the plot
> pimg=zeros(size(img)+[1,1]);
> pimg(1:end-1,1:end-1)=img;
> ph=pcolor(pimg);
> shading flat; % <- or shading interp
> line(x,y,z,...
> 'marker','.',...
> 'markerfacecolor',[0,0,1],...
> 'linestyle','none',...
> 'color',[0,0,1]);
> alpha(ph,.8);
> view(30,30);
>
> us

Subject: Show Image in Plane of 3D Axes

From: Jerome Briot

Date: 8 Sep, 2007 10:28:21

Message: 4 of 5

"Andrew Zalesky" wrote :
> However, how do I shift the image from the Z = 0 plane to
> the plane Z = 10? Or some other plane such as X = 10.

Hi,

try this :

load clown

figure
colormap(map)
surface('XData',[0 1;0 1],...
   'YData',[0 0;1 1],...
   'ZData',[10 10; 10 10],...
   'CData',X,...
   'FaceColor','texturemap');

view(3)

Jérôme

Subject: Show Image in Plane of 3D Axes

From: us

Date: 8 Sep, 2007 11:49:11

Message: 5 of 5

Jerome Briot:
<SNIP another good solution...

> surface('XData',[0 1;0 1],...
> 'YData',[0 0;1 1],...
> 'ZData',[10 10; 10 10],...
> 'CData',X,...
> 'FaceColor','texturemap');

...- unfortunately - with a flaw...

yes, this works as long as the OP does NOT need to use

     shading interp;

this causes no problem with the <pcolor> approach, which,
by the way, uses <surface>s in its engine...

anyhow, here's a solution with an addition z-value - note,
you could define any z-surface you want/need

% some data
% ...the image
     m=load('clown');
     img=flipud(m.X);
% ...the x/y/z
     x=1:size(img,2);
     y=100*ones(size(x));
     z=50*sind(x);
% the plot
     pimg=zeros(size(img)+[1,1]);
     pimg(1:end-1,1:end-1)=img;
     ph=pcolor(pimg);
     zd=get(ph,'zdata');
     set(ph,'zdata',10*ones(size(zd)));
% -or- try this for fun
% set(ph,'zdata',10*rand(size(zd)));
     shading interp; % <- or shading flat,...
     line(x,y,z,...
         'marker','.',...
         'markerfacecolor',[0,0,1],...
         'linestyle','none',...
         'color',[0,0,1]);
     alpha(ph,.8);
     view(30,30);

us

Tags for this Thread

Everyone's Tags:

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.

Tag Activity for This Thread
Tag Applied By Date/Time
3d Andrew 1 Dec, 2010 20:10:05
graphics Jan Skapa 1 Feb, 2008 03:02:29
3d us 7 Sep, 2007 22:20:22
2d us 7 Sep, 2007 22:20:22
view us 7 Sep, 2007 22:20:22
plot us 7 Sep, 2007 22:20:21
line us 7 Sep, 2007 22:20:21
pcolor us 7 Sep, 2007 22:20:21
graphics us 7 Sep, 2007 22:20:21
code us 7 Sep, 2007 22:20:21
rssFeed for this Thread

Contact us at files@mathworks.com