How can I extract each connected object in a 3D array?

2 次查看(过去 30 天)
I have a 3D array (attached as Y.mat) and I find the connected components using bwconncomp. I used the following coding to extract each component but X is a zero array with the same size as Y. Please, help me to solve this problem.
Thanks
May
CC = bwconncomp(Y, 26); % Y is the 3D array
L = labelmatrix(CC);
for i=1:length(CC.PixelIdxList)
X = (L==i);
imshow3D(a); % use existing function to show 3D
end

采纳的回答

Image Analyst
Image Analyst 2017-3-1
Use ismember
oneBlobOnly = ismember(L, i);
  2 个评论
May
May 2017-3-2
Thanks Image Analyst,I tried it but the result is not change. Please kindly help me , where I made wrong. Thank you so much again.
load Y;
CC = bwconncomp(Y, 26); % Y is the 3D array
L = labelmatrix(CC);
oneBlobOnly = ismember(L,2);
map = hsv(90);
XR = oneBlobOnly; %%If I show "Y", it can show.
Ds = smooth3(XR);
hiso = patch(isosurface(Ds,5),'FaceColor','blue','EdgeColor','none');
hcap = patch(isocaps(XR,5),'FaceColor','interp','EdgeColor','none');
colormap(map)
daspect(gca,[1,1,.4])
lightangle(305,30);
fig = gcf;
fig.Renderer = 'zbuffer';
lighting phong
isonormals(Ds,hiso)
hcap.AmbientStrength = .6;
hiso.SpecularColorReflectance = 0;
hiso.SpecularExponent = 50;
ax = gca;
ax.View = [215,30];
ax.Box = 'On';
axis tight
title('One Blob');

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by