I'm working on a piece of code in MATLAB using the Image Processing Toolbox, where I've used Skel=bwmorph(BM,'skel') to get a skeleton of a river. I want to use BP=bwmorph(Skel,'branchpoints') to get the points where confluences and tributaries exist. I'm getting a lot of false positives in BP whenever the skeleton looks like
oQo
Q
o
It marks the Q pixels as branch points as well, along with the actual, expected branch points. There are a lot of false positives like that.
I have noticed that a true branch point occours as an isolated pixel in BP, while fals branch points always form in pairs.
Can anyone please tell me how the branchpoints algorithm finds the points? If I know that, I can be satisfied that there is an actual reason why the false positives are in pairs, and true positives are alone, rather than a lucky coincidence.
I have a feeling it looks at the 8-connectivity around the pixel, but I think that's not all it does.
To clarify, I've marked a cropped image of the output. The positives it gives are shown in red. As can be seen, just one of these pixels is actually a branch point. I want to know how the algorithm works so that I can give a logical reason for why false positives come in pairs (if they infact do).
The image
Your pixels are not minimally (8-)connected, try to use
Thin = bwmorph(Skel,'thin');
BP = bwmorph(Thin,'branchpoints');
to remove the unnecessary pixels. (You could also use thin instead of skel).
I think the basic algorithm of branchpoints looks at the 3,3 neighbourhood pixels if at least 3 pixels (excluding center) are '1'.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With