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:
Surface Plotting Over an Image

Subject: Surface Plotting Over an Image

From: E

Date: 7 Jan, 2011 18:26:05

Message: 1 of 3

Hi,

I'm trying to use the "surfc" function to plot a color gradient plot over an image. My "x" and "y" data are the pixel coordinates, and a third matrix holds the "intensity" values at each pixel. When I plot the surface plot over the image, it seems to fall in the correct position, but the surface plot area is entirely black. When I plot the surface plot as separate figure, the color gradient appear correctly. What can I do to make the color gradient appear on the image overlay plot?

I've already tried removing the edge line color.
 set(h, 'edgecolor','none')

Thanks,
Evan

Subject: Surface Plotting Over an Image

From: E

Date: 7 Jan, 2011 18:37:05

Message: 2 of 3

"E" wrote in message <ig7lrt$fkg$1@fred.mathworks.com>...
> Hi,
>
> I'm trying to use the "surfc" function to plot a color gradient plot over an image. My "x" and "y" data are the pixel coordinates, and a third matrix holds the "intensity" values at each pixel. When I plot the surface plot over the image, it seems to fall in the correct position, but the surface plot area is entirely black. When I plot the surface plot as separate figure, the color gradient appear correctly. What can I do to make the color gradient appear on the image overlay plot?
>
> I've already tried removing the edge line color.
> set(h, 'edgecolor','none')
>
> Thanks,
> Evan

Maybe a bit code is helpful to look at
 fig=figure;
        imshow(image)
        hold on
        
        h=mesh(pixel_matrix(:,:,1),pixel_matrix(:,:,2),pixel_matrix(:,:,3))
      
        set(h, 'edgecolor','none')

Subject: Surface Plotting Over an Image

From: Sean de

Date: 7 Jan, 2011 18:40:20

Message: 3 of 3

"E" wrote in message <ig7lrt$fkg$1@fred.mathworks.com>...
> Hi,
>
> I'm trying to use the "surfc" function to plot a color gradient plot over an image. My "x" and "y" data are the pixel coordinates, and a third matrix holds the "intensity" values at each pixel. When I plot the surface plot over the image, it seems to fall in the correct position, but the surface plot area is entirely black. When I plot the surface plot as separate figure, the color gradient appear correctly. What can I do to make the color gradient appear on the image overlay plot?
>
> I've already tried removing the edge line color.
> set(h, 'edgecolor','none')
>
> Thanks,
> Evan

You'll have to use different colormaps. See my function
meshCanopy on the FEX:
http://www.mathworks.com/matlabcentral/fileexchange/29485-meshcanopy

Even if this isn't exactly what you want, the code inside should help you understand colormap assignments.

Also, when you say you want a surface plot, depending on how big the surface is, a mesh is usually better. Surfaces just appear black due to the density. To use a surface with the meshCanopy function, you could replace the one call to mesh with surf.

Good Luck!
-Sean

Tags for 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