bwconncomp reports only one connected component when there are obviously many hundreds
5 次查看(过去 30 天)
显示 更早的评论
I have the 3D binary image shown below and I am trying to extract the largest connected component
As you can see there are many separate components but when I use the function
bwconncomp
it tells me there is only one connected component like this
> cc=bwconncomp(imt2,6)
cc =
struct with fields:
Connectivity: 6
ImageSize: [176 256 20]
NumObjects: 1
PixelIdxList: {[432548×1 double]}
Where imt2 is my image. The same thing happens if I use 26 for connectivity.
I have attached the imt2 data.
Is this a matlab bug or am I misunderstanding something?
2 个评论
DGM
2023-9-11
I think you're being confused by the way you're visualizng the data. You're looking at the surface of a solid volume:
load imt2.mat
isosurface(imt2)
axis equal
All those things that look like isolated points are the interior surfaces of voids in the solid. We can just take the average on Z and see that the object is solid and there aren't any stray pixels that are isolated (at least as far as this single projection can tell).
A = mean(double(imt2),3);
imshow(A,'border','tight')
采纳的回答
Image Analyst
2023-9-11
There is just one connected, semi-porous blob as you can see from the screenshot below:
s = load('imt2.mat')
imt2 = s.imt2;
props = regionprops3(s.imt2, 'Volume')
volshow(imt2)
更多回答(1 个)
Walter Roberson
2023-9-11
load imt2
M = false(size(imt2));
M(end/2,end/2,end/2) = true;
OUT = bwdistgeodesic(imt2, M, 'cityblock');
MMM=(isnan(OUT) & imt2);
nnz(MMM)
This tells you that if you mark the center of the matrix, and ask bwdistgeodesic to traverse only through city block operations, that every location in the matrix that cannot be reached from the centre, is also a false pixel.
To flip that around: every pixel that is true can reach the center pixel using only cityblock operations -- moving up / down / left / right / forward / back without diagonals.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 3-D Volumetric Image Processing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!