From: Els on
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
From: kinor on
"Els " <y.e.t.reeuwijk(a)student.utwente.nl> wrote in message <hltj2e$ci6$1(a)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
From: Els on
Perfect! And if I want to do this for multiple objects, can I plot them all in one image?
From: Els on
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?