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:
RGB 2D slice in a 3D plot

Subject: RGB 2D slice in a 3D plot

From: Els

Date: 22 Feb, 2010 09:34:06

Message: 1 of 4

Hello,

I made a program in which I segmented a certain RGB object from a picture.
In the image, only the RGB pixels are shown and the surrounding pixels I gave a zero-value.

Now I want to plot only the RGB slice in a 3D plot, without the surrounding pixels. So that the surrounding is transparant. Does anyone have suggestions how I can achieve this? In another program I did this by changing the alpha channel.

When this is done, I want to plot multiple object by this method in the same 3D plot.
Is this possible?

A lot of thanks in advance

Subject: RGB 2D slice in a 3D plot

From: kinor

Date: 22 Feb, 2010 12:19:05

Message: 2 of 4

"Els " <y.e.t.reeuwijk@student.utwente.nl> wrote in message <hltj2e$ci6$1@fred.mathworks.com>...
> Hello,
>
> I made a program in which I segmented a certain RGB object from a picture.
> In the image, only the RGB pixels are shown and the surrounding pixels I gave a zero-value.
>
> Now I want to plot only the RGB slice in a 3D plot, without the surrounding pixels. So that the surrounding is transparant. Does anyone have suggestions how I can achieve this? In another program I did this by changing the alpha channel.
>
> When this is done, I want to plot multiple object by this method in the same 3D plot.
> Is this possible?
>
> A lot of thanks in advance

Hi,
you could use slice and erase the patches you do not want to be displayed like in the example below by setting one coordinate to nan

[x,y,z] = meshgrid(-2:.2:2,-2:.25:2,-2:.16:2);
v = x.*exp(-x.^2-y.^2-z.^2);
xslice = [-1.2,.8,2]; yslice = 2; zslice = [-2,0];
sh = slice(x,y,z,v,xslice,yslice,zslice)
colormap hsv
% kill a part of sh(1)
get(sh(1))
xd = get(sh(1), 'XData');
xd(1:10,:) = nan;
set(sh(1), 'XData', xd);

hth
k

Subject: RGB 2D slice in a 3D plot

From: Els

Date: 22 Feb, 2010 12:48:05

Message: 3 of 4

Perfect! And if I want to do this for multiple objects, can I plot them all in one image?

Subject: RGB 2D slice in a 3D plot

From: Els

Date: 23 Feb, 2010 07:48:37

Message: 4 of 4

The problem is still, if I use the suggested code, a volume must be created. And I only have a 2D RGB (NxMxI) image, which I want to plot in 3D. So I understand now that the zeros have to be replaced by nan.

But how do I plot this in a 3D mesh?

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