pythonimageopencvimage-processingscikit-image

Python Image - Finding largest branch from image skeleton


I have a skeletonized image in the following shape: enter image description here

And I want to extract the "largest branch" from the skeleton: enter image description here

I know that maybe I need to extract the junction point and divide de lines from that point(?), but I have no clue how to do that.

Is there any way to do that with Python Scikit Image or OpenCV?


Solution

  • I believe you can use OpenCV to do the following:

    1. Use HarrisCorner to detect all corners in the image. This will get you the shown three green points (I drew a whole circle to highlight the location).

    enter image description here

    1. Add a black pixel at all corners

    2. Get all branches in the picture using findContours. Then check the length of each contour using arcLength and get the longest.