How does bwmorph define a branch point

5 views (last 30 days)
Matt J
Matt J on 24 Jun 2016
Commented: Matt J on 28 Jun 2016
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 Comment
Matt J
Matt J on 28 Jun 2016
In case anyone wants to try to reproduce this, I've attached the test image.

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 26 Jun 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 Comments
Image Analyst
Image Analyst on 27 Jun 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 on 28 Jun 2016
Edited: Matt J on 28 Jun 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.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!