TransWikia.com

Circle-based skeletonization demonstration

Mathematica Asked on January 12, 2021

Skeletonization (or the medial-axis transform) is the process of finding the "middle" axis of a region (expressed as a mask). It is performed by the SkeletonTransform, which seems to work by thinning the mask until the "frontiers" meet, where they define the medial-axis.

There is another method, based on growing circles, which is my concern.

Consider this mask of a horse head:

enter image description here

Suppose you start with the small red circle that is bi-tangent to the boundary of the mask (i.e., touches the mask boundary in at least two points, as shown below).

enter image description here

This alternate method incrementally increases the radius of the circle and automatically adjusts the position of a new center so as to retain this bi-tangency condition.

The example image above is a hack… a kludge… based on selecting some candidate circle centers and increasing the radius until two (or more) points touch the boundary of the mask.

I would like to perform this process properly and algorithmically.

My general approach was to take the current largest circle, increment its radius by a small amount (e.g., by 1 pixel), then search for the circle center that is nearest the center of the current largest that retains bi-tangency. I think there are clever region-based primitives in Mathematica that could make efficient code, but alas I simply am not familiar enough with region-based computations. Moreover, functions such as RegionMemberQ don’t directly correspond to bi-tangency.

Ultimately, I’d like to color the circles and associated line linking centers, as kludged above.


@bills’ suggestion about RidgeFilter (new to me) really helped!

enter image description here

I just need to fine tune thresholds and such.

One Answer

It may not give everything you are looking for, but:

img = Import["https://i.stack.imgur.com/zV7QC.png"];
RidgeFilter[DistanceTransform[img],0.5] // ImageAdjust

enter image description here

These are the ridges, which should be the centers of your circles. The radii would be the value of the Distance Transform image at these centers.

Answered by bill s on January 12, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP