How does bwmorph define a branch point

I have attempted, with the following code,
skel=bwmorph(msk,'skel',inf);
bw = skel&~bwmorph(skel,'branchpoints');
to remove the branch points from skeletonized binary image "skel" resulting in image "bw". Here is a section of skel,
and here is the result, bw, where one can see that only one of the branches was successfully disconnected.
I am wondering why this occurred. I assume I have a mistaken notion of what bwmorph considers a branch point, but then, what does qualify as a branch point? If it is a white pixel with at least 3 white neighbors, then what I attempted should have worked.
I know I could use bwlookup to search for pixels meeting my criteria, but I'm wondering why bwmorph(...,'branchpoints') isn't right for this.

1 comentario

Matt J
Matt J el 28 de Jun. de 2016
In case anyone wants to try to reproduce this, I've attached the test image.

Iniciar sesión para comentar.

Respuestas (1)

Image Analyst
Image Analyst el 26 de Jun. de 2016
The documentation doesn't say exactly but I bet the algorithm is that it looks for a pixel surrounded by 3 or more neighbors. For such pixels, the output image will be true at that pixel location. It looks like you then XORed the branchpoint image with your original image to have the branchpoints removed. Yes, for 4-connected situations, the removal will leave the image branches connected in the 8-connected sense. For them not to be 8-connected, you'll have to dilate the branchpoint image with
bpImage = imdilate(bpImage, true(3))
before XORing it.

8 comentarios

Matt J
Matt J el 26 de Jun. de 2016
I don't think the issue could be 8- vs. 4-connectivity. In the image I showed, neither connection point had 3 or more 4-connected neighbors, yet one of them was removed.
Walter Roberson
Walter Roberson el 26 de Jun. de 2016
Look near line 61 of toolbox/images/images/+images/+internal/algbwmorph.m
Image Analyst
Image Analyst el 26 de Jun. de 2016
I didn't say anything about the connectedness of the points when determining whether it's a branchpoint. Matt, check again. Each location had 3 neighbors - it doesn't care if they're 4-connected or 8-connected, all it cares is if there are 3 or more neighbors anywhere in the 8 neighbors. However, once those branchpoints are blackened, whether the remaining branches are connected or not does depend on whether you are considering 4-connected or 8-connected. I don't think any situation would be considered connected if you're using 4-connectedness, but there are still certain patterns that would be considered connected if you're using 8-connectedness once you remove the branchpoint pixels.
Matt J
Matt J el 27 de Jun. de 2016
Editada: Matt J el 28 de Jun. de 2016
Sorry, I'm still not following. There is clearly a white pixel that had 3 white neighbors in the original image, yet was not blackened. I have a yellow arrow (the lower one) pointing to the non-blackened pixel.
Matt J
Matt J el 27 de Jun. de 2016
Look near line 61 of toolbox/images/images/+images/+internal/algbwmorph.m
Thanks, Walter. I can't quite decipher the reasoning in the code there, but it appears that there is more to determining a branch point than just number of neighbors.
Sean de Wolski
Sean de Wolski el 27 de Jun. de 2016
My understanding is that if you now do a connected components analysis using 4-connectivity, the three (or four for a perfect cross) branches at both of those junctions will no longer be connected components and therefore bwmorph(...,'branchpoints') was successful.
Image Analyst
Image Analyst el 27 de Jun. de 2016
Matt, I see what you mean now - I was looking at the wrong pixel (the one that got removed) because the tips of your arrows do not precisely land on any pixel but just point in the general direction).
Sean, I think that since Matt is starting with a single 8-connected object, he expected after XORing branchpoints that he would now have 5 separated 8-connected regions, but he ends up with only 2. Is there any way to end up with that, other than the branchpoint dilation which I already suggested?
Steve Eddins discussed this exact situation (same shape even!) in his blog: http://blogs.mathworks.com/steve/2014/01/07/automating-data-extraction-2/?s_tid=srchtitle
Matt J
Matt J el 28 de Jun. de 2016
Editada: Matt J el 28 de Jun. de 2016
he expected ... that he would now have 5 separated 8-connected regions, but he ends up with only 2. Is there any way to end up with that, other than the branchpoint dilation which I already suggested?
This worked fine,
skel=bwmorph(msk,'thin',inf);
bp=bwlookup(skel, makelut(@(x) sum(x(:))>=4 & x(5)==1,3)); %branch points?
bw=skel&~bp;
but I'm still wondering what bwmorph is doing, if it's not supposed to be equivalent to "bp" above.

Iniciar sesión para comentar.

Etiquetas

Preguntada:

el 24 de Jun. de 2016

Comentada:

el 28 de Jun. de 2016

Community Treasure Hunt

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

Start Hunting!

Translated by