Skip to content Skip to sidebar Skip to footer

Centerline Of A Polygonal Blob (binary Image)

I have a binary image of a worm (blob extraction which works well). I am interested in fitting a centerline on the blob (worm). So far I came up with this: starting from a polygon

Solution 1:

I have found a better solution:

  • skeltonize the binary blob
  • build the graph (without cycles) of the skeleton by tracing pixel lines and branch points
  • get all shortest paths from each end node to all other end nodes and take the longest one (approximately the start and end of the blob)
  • the resulting path from one end node (degree=1) to another end node is an approximation of the worm middle line.

If someone is interested in the solution, I may share a python notebook. end result: green= final midline graph, dark green=final midline

the graph of the skelton

Source Code: The code to this question can be found here: https://github.com/gabyx/WormAnalysis (if you use it please star it)

Post a Comment for "Centerline Of A Polygonal Blob (binary Image)"