# Find cylinder-like sub-regions of a geometric surface or mesh

We are creating iso-surfaces, from CT scan data, using thresholds to get regions of higher intensity value and using a connected components filter to split the result into multiple sub-regions.

Within these sub-regions, we would like to find approximately cylinder-like objects within the data. Examples of such objects would be pins or screws as seen in orthopedic surgeries. Our size target for the cylinders is roughly 0.5 mm to 10 mm in diameter, and 1 mm to 30 mm in length.

Are there any classes pre-built within ITK which would help us with this task? We are tackling it independently, but would welcome any pointers on / links to “code that’s out there already.”

Hello David,

The labeled image components could be filtered based on LabelShapObject attributed computed int the LabelImageToShapeLabelMapFilter.

Here is an example of computing the attributes:
https://itk.org/ITKExamples/src/Filtering/LabelMap/ShapeAttributesForBinaryImage/Documentation.html

Thanks for that pointer.

We can already identify things that are approximately cylinders in and of themselves at the labelled region level.

What we are having difficulty doing is finding a “cylinder” within a labelled region that has a cylindrical sub-region, but is not really close to a cylinder itself. So think of a pin sticking out of a cube or block, where the pin is maybe 0.25x the size of the block, but they “blend together” in the same labelled region because the pin cannot be thresholded well from its surroundings.

So I guess the question is: is there an easy way to find all the cylinder like sub-regions on the surface of a larger region?

Hello @dlrdave,

From your description this sounds more of a surface fitting problem. Outside the scope of ITK, but possibly fitting a cylinder to the cloud of 3D surface points via RANSAC?

ITK does have point set registration methods, and you could use a strategy that involves a “template” cyclinder and registers it to the points from the surface of the connected components.

However, it may be easier to use the `itk::HessianToObjectnessMeasureImageFilter on a denoised version of the input image, which will enhance cylinder-like structures of a certain size, then follow through with thresholding, connected components, etc.