bwconncomp reports only one connected component when there are obviously many hundreds

5 vues (au cours des 30 derniers jours)
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 commentaires
DGM
DGM le 11 Sep 2023
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')
Michael
Michael le 11 Sep 2023
Of course. I wrote my own version of volshow that uses isosurface and it had a bug in that if the volume ran all the way to the edges it would not show the edge planes. I have fixed that and this is what the actual image looks like:

Connectez-vous pour commenter.

Réponse acceptée

Image Analyst
Image Analyst le 11 Sep 2023
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 commentaire
Michael
Michael le 11 Sep 2023
Of course. I wrote my own version of volshow that uses isosurface and it had a bug in that if the volume ran all the way to the edges it would not show the edge planes. I have fixed that and this is what the actual image looks like:

Connectez-vous pour commenter.

Plus de réponses (1)

Walter Roberson
Walter Roberson le 11 Sep 2023
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)
ans = 0
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.
  1 commentaire
Michael
Michael le 11 Sep 2023
Thanks Walter. Very useful to know this function!.
Also, now I understand why connectivity of 26 is more promiscuous than connectivity 6. 26 lets you have any the possible diagonals and still be connected whereas 6 doesn't allow any.
I was looking at it the wrong way around and expecting 26 to be more restrictive because I thought it demanded that ALL the diagonals be filled and that with 6, only one connecting point in a face was required.
Michael

Connectez-vous pour commenter.

Catégories

En savoir plus sur 3-D Volumetric Image Processing dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by