bwlabeln 3D connections not a subset of its 2D connections

4 views (last 30 days)
Brian Frost
Brian Frost on 17 May 2022
Commented: Brian Frost on 18 May 2022
Hi all -
I am trying to use bwlabeln to connect a single flat membrane apparent in a large OCT volume scan. When I use bwconnect on cross-section, or bwlabeln with either 4 or 8 as the connect parameter, all is well. Of course, this is undesirable as it means my connected regions are only in-plane.
However, when I use 6, 26 or any other 3D parameter for connect, I do not get the desired result. I find this confusing, because my understanding is that if two pixels are connected in 2D, they ought still be connected in 3D. As such, the connected region using '4' should be a subset of that using '6'. Am I incorrect here? How can I achieve the desired result.
Here is my code, and the figures generated. I have labeled the membrane I want to connect.
label4 = bwlabeln(VThresh2,4);
label26 = bwlabeln(VThresh2,26);
title('Slice 256 Binary Image')
title('Slice 257 Binary Image')
subplot(3,2,[3 5])
title('Slice 256 Connected Regions using connect=4')
subplot(3,2,[4 6])
title('Slice 256 Connected Regions using connect=26')

Accepted Answer

Matt J
Matt J on 18 May 2022
Edited: Matt J on 18 May 2022
My guess is that the 4-connected regions are indeed subsets of the 26-connected regions, as you expect. However, in the 26-connected case, you now have a wider range of labels per slice. Therefore, the grayscale range of your image displays is wider, thereby hiding some of the blobs.
  1 Comment
Brian Frost
Brian Frost on 18 May 2022
I am a bit embarrassed, but you are correct! In the image, it not only shows up dark but the index literally shows as zero when you hover over it, really hiding the fact that it was present. When I ask it to spit out the pixel value at a point in the blob, it reads 5 -- the smallest number in the world.
Thanks so much!

Sign in to comment.

More Answers (1)

Image Analyst
Image Analyst on 18 May 2022
If an blob is 4-connected to a voxel then it will be 6-connected to the same voxel. However the converse is not true. A blob that is 6-connected in 3-D may not appear to have any 4-connected blobs if you look at just a single slice. A slice may have two separate, unconnected blobs in that particular slice, however you may be connected vertically by a, let's call it, "bridge" in adjacent slices. Like there may be a path up from the centroid of blob 2 in that slice up to the slice above and then a path over to just above the blob #1 and then goes down to blob #1 to make them connected. So the one slice it seems like there are 2 unconnected blobs but because of bridge connecting them in other slices, they are still 6-connected in 3-D.

Community Treasure Hunt

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

Start Hunting!

Translated by