8

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 (after outline extraction of blob in the image) I applied a voronoi computation and discarded all vertices which are outside of the polygon (blue) which gave me the black center line which I can further use to fit a smooth centerline.

However, this computation is not at all robust (due removing voronoi vertices not inside the polygon?) Does somebody know an algorithmic workflow to get the centerline of a polygon or the center line of a blob object (binary image). (skeletonization?, triangulation of polygon an using midpoints of inside edges)

Here is a demonstration:

enter image description here

Gabriel
  • 8,990
  • 6
  • 57
  • 101

1 Answers1

6

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)

Gabriel
  • 8,990
  • 6
  • 57
  • 101
  • That looks great! Could you share your python notebook with me indeed? Thanks! – crazjo Nov 30 '17 at 11:56
  • Of course, I will post tonight something, I have already prepared, a while ago... need to find it... – Gabriel Nov 30 '17 at 12:35
  • Hi @Gabriel, I’m using the approach you've described, but am having some issues, as outlined here: https://stackoverflow.com/questions/53436517/finding-midlines-of-polygons-using-voronoi-diagrams I was wondering if you had any tips on how to implement the suggestions made by Ante to either incorporate information about the amount of “boundary area” traced by the midline, extend the midline when it "stops" on a point that is medial axis of clean "circular" arc, or even just prune the graph to eliminate spurs that trace long, but clearly “non-midline” paths. Thanks a ton! – shbrainard Dec 14 '18 at 14:07