Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
2d Image on the x-y plane of a 3d plot?

Subject: 2d Image on the x-y plane of a 3d plot?

From: Fo

Date: 6 Oct, 2008 15:25:45

Message: 1 of 6

Dear all,
sorry if this question has been already answered but I couldn't find
anywhere how to do it.
My problems are simple.
1. In a mesh() plot, can I define a surface to be transparent? Should
I do it with FaceAlpha?Which property of which object should I set?
2. How can I plot an image (raster- jpg or bmp) on the x-y plane of a
3d plot? Should I set some axes property? Can I set an image() as the
background?
I am working on MATLAB Version 7.1.0.246 (R14) Service Pack 3.
Thank you for your help!

Fortunato TE

Subject: 2d Image on the x-y plane of a 3d plot?

From: pluton

Date: 6 Oct, 2008 16:22:41

Message: 2 of 6

could you please post a piece of code so that we can start with
something ?
Thank you

Subject: 2d Image on the x-y plane of a 3d plot?

From: Fo

Date: 6 Oct, 2008 19:32:36

Message: 3 of 6

Sorry that I didn't post any code.

Here a piece of code
Maybe it helps to explain the problem

%Generate a surface to plot in 3d
z=peaks();
%Generate an image to plot on the xy plane (z=0)
imOnXY=image(rand([size(peaks,1),size(peaks,2),3]));
ff=figure();
view([-30 20]);
%Show the image
imshow(imOnXY);
hold on
%plot the z matrix as surface
surface(z,'FaceAlpha',0.5,'LineStyle','none','FaceColor','interp');



On 6 okt, 17:22, pluton <legrand.math...@gmail.com> wrote:
> could you please post a piece of code so that we can start with
> something ?
> Thank you

Subject: 2d Image on the x-y plane of a 3d plot?

From: pluton

Date: 7 Oct, 2008 15:19:20

Message: 4 of 6

is this what you want ?

clear all; close all; clc
%Generate a surface to plot in 3d
z=peaks;
%Generate an image to plot on the xy plane (z=0)
imOnXY=rand([size(peaks,1),size(peaks,2),3]);
figure(1);
%Show the image
x=0*peaks-10;
hold on
surface(x,imOnXY,'FaceColor','texturemap','EdgeColor','none','CDataMapping','direct')
surface(z,'FaceAlpha',0.5,'LineStyle','none','FaceColor','interp');
axis on
view(-35,45)

Subject: 2d Image on the x-y plane of a 3d plot?

From: Fo

Date: 8 Oct, 2008 05:54:03

Message: 5 of 6

On Oct 7, 5:19=A0pm, pluton <legrand.math...@gmail.com> wrote:
> is this what you want ?
YEES!!!
That was it!!!
Thank you a lot!
Fortunato

>
> clear all; close all; clc
> %Generate a surface to plot in 3d
> z=3Dpeaks;
> %Generate an image to plot on the xy plane (z=3D0)
> imOnXY=3Drand([size(peaks,1),size(peaks,2),3]);
> figure(1);
> %Show the image
> x=3D0*peaks-10;
> hold on
> surface(x,imOnXY,'FaceColor','texturemap','EdgeColor','none','CDataMappin=
g','direct')
> surface(z,'FaceAlpha',0.5,'LineStyle','none','FaceColor','interp');
> axis on
> view(-35,45)

Subject: 2d Image on the x-y plane of a 3d plot?

From: Joachim

Date: 15 Aug, 2013 12:39:24

Message: 6 of 6

Hello,

Currently I'm trying to find a solution to a similar problem.
I would like to display two-dimensional RGB images not only on the (x,y)-plane
but also on the (x,z)- and (y,z)-plane.
However, only the image in the (x,y)-plane is displayed.

The code for the assignment of the images reads as follows:

surface(w3,w2,w1(end).*ones(ny,nz),sxRGBimage,'FaceColor','texturemap','EdgeColor','none','CDataMapping','direct');
  surface(w3,w1,w2(end).*ones(nx,nz),syRGBimage,'FaceColor','texturemap','EdgeColor','none','CDataMapping','direct');
  surface(w2,w1,w3(1).*ones(nx,ny),szRGBimage,'FaceColor','texturemap','EdgeColor','none','CDataMapping','direct');

Thereby the vectors w1, w2 and w3 define x-, y- and z-axis and their size is nx, ny and nz, respectively. The RGB images are denoted as sxRGBimage, syRGBimage and szRGBimage.

In addition, I use the following code to generate the 3D representation:

ha=gca;
set(gca,...
  'XLim',sort([w1(1),w1(end)]),...
  'YLim',sort([w2(1),w2(end)]),...
  'ZLim',sort([w3(1),w3(end)]));
if strcmpi(tick_mode,'man'),
  set(gca,...
    'XTick',ticks,...
    'YTick',ticks,...
    'ZTick',ticks)
end
if strcmpi(label_mode,'man'),
  set(gca,...
    'XTickLabel',labels,...
    'YTickLabel',labels,...
    'ZTickLabel',labels);
end

daspect([100 100 4]);
view(3);
camproj(projection_type);

if flag_xlabel,xlabel('\omega_{\tau} (cm^{-1})');end
if flag_ylabel,ylabel('\omega_{t} (cm^{-1})');end
if flag_zlabel,zlabel('\omega_{T} (cm^{-1})');end

set(gca,'TickDir','out')

axis vis3d

title(datatype);

if nargout>=1
  varargout{1}=ha;
end

Do you have an idea how to modify the code to display the images on all coordinate planes? Thanks for any hints which might be helpful to resolve this issue.

Best regards,

Joachim

Tags for this Thread

No tags are associated with this thread.

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.

Contact us