ITKLabelPointSet

ITK Module to extract a PointSet from a labeled image

APACHE-2.0 License

Downloads
2.1K
Stars
0

ITKLabelPointSet

Overview

This is a module for the Insight Toolkit (ITK). The module includes a filter to extract a PointSet from a labeled image. Additional filters and IO classes may be added in future versions to support pointset registration workflows.

    import itk

    labels = itk.imread('path/to/labelmap.mha').astype(itk.US)
    D = labels.ndim

    ImageType = type(labels)
    PointSetType = itk.PointSet[itk.US, D]

    extractor = itk.LabelToPointSetFilter[ImageType, PointSetType].New()
    extractor.SetInput(labels)
    extractor.Update()
    point_set = extractor.GetOutput()

    data = point_set.GetPointData()
    for i in range(point_set.GetNumberOfPoints()):
      print(f"{i}: {point_set.GetPoint(i)}, {data.GetElement(i)}")

Installation

To install the binary Python packages:

  python -m pip install itk-labelpointset