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 plot/mesh out of digital images

Subject: surface plot/mesh out of digital images

From: nman2084

Date: 16 May, 2011 21:31:03

Message: 1 of 7

Can some direct me where i can get more information in how to do a surface plot or mesh out of digital image taken by a camera.

Subject: surface plot/mesh out of digital images

From: ImageAnalyst

Date: 17 May, 2011 01:17:40

Message: 2 of 7

On May 16, 5:31 pm, "nman2084 " <ng2...@yahoo.com> wrote:
> Can some direct me where i can get more information in how to do a surface plot or mesh out of digital image taken by a camera.

-------------------------------------------------------------
First get a monochrome image. If you are starting with a color image,
use this code
grayImage = rgb2gray(rgbImage);
or this code:
redChannel = rgbImage(:,:,1);
greenChannel = rgbImage(:,:,2);
blueChannel = rgbImage(:,:,3);

Once you have that you can use the surf() function to plot the
intensity as a surface in 2.5-dimensional space. (I don't consider a
surface plot a 3D plot because there is no third dimension - you have
a row (y), and a column (x), and a value just like a regular 2D
matrix, yet it is rendered as a height so it's kind of 3D but not
really)

Subject: surface plot/mesh out of digital images

From: nman2084

Date: 18 May, 2011 19:51:04

Message: 3 of 7

I tried this code it did not give error but the figure is empty, but i did get a warning:

Warning: CData must be double or single unless it is used only as a texture data



rgbImage = imread('ball1.jpg');
redChannel = rgbImage(:,:,1);
greenChannel = rgbImage(:,:,2);
blueChannel = rgbImage(:,:,3);
surf(redChannel, greenChannel, blueChannel);

image is 300 X 300 X 3

Subject: surface plot/mesh out of digital images

From: ImageAnalyst

Date: 18 May, 2011 20:07:48

Message: 4 of 7

You need to plot one surface at a time. You can't pass in all 3 at
once.
surf(redChannel);
hold on;
surf( greenChannel);
surf( blueChannel);

Give that a try.

Subject: surface plot/mesh out of digital images

From: nman2084

Date: 18 May, 2011 20:37:04

Message: 5 of 7

Thanks sir,
      Is there a way to get any information of the measurements of the object in the picture (real object), like for this instance diameter, volume etc.

Subject: surface plot/mesh out of digital images

From: ImageAnalyst

Date: 18 May, 2011 21:13:43

Message: 6 of 7

On May 18, 4:37 pm, "nman2084 " <ng2...@yahoo.com> wrote:
> Thanks sir,
>       Is there a way to get any information of the measurements of the object in the picture (real object), like for this instance diameter, volume etc.
----------------------------------------------------------------------------------------------------
Of course. That is what image analysis and image processing are all
about!

See my demos:
http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862

Subject: surface plot/mesh out of digital images

From: Harold Bell

Date: 11 Dec, 2012 20:25:08

Message: 7 of 7

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <30e53e56-154c-4cc1-9780-691a03532db6@b42g2000yqi.googlegroups.com>...
> You need to plot one surface at a time. You can't pass in all 3 at
> once.
> surf(redChannel);
> hold on;
> surf( greenChannel);
> surf( blueChannel);
>
> Give that a try.

Hi - I came across this same issue and I did try the code you wrote above on my own, but still had an empty figure. I also still get:
Warning: CData must be double or single unless it is used only as a
texture data
Any thoughts?

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