Working with label maps

Hi!

I am wondering if I can use Label Maps to get simple stats of my connected components.

I have a binary image img and I have done this:

  cc = sitk.ConnectedComponentImageFilter()
  img2 = cc.Execute(img)

This gives me an image with labels.

How can I then use Label Maps to select specific components, count the number of pixels etc. Moreover, is that the purpose of label maps?

Thanks!

Hello @Diego_C,

What you want is the LabelShapeStatisticsImageFilter. Example usage can be found in the Segmentation_Shape_Analysis

1 Like

Hello,

To compute statistics there are LabelStatisticsImageFilter, LabelShapeStatisticsImageFilter and the LabelIntensityStatisticsImageFilter filters. These filters work on Images not LabelMaps.

The BinaryImageToLabelMap filter does a similar operation to the ConnectedComponents filter but produces a LabelMap type image.

There are a set of filters in ITK/SimpleITK that end in “LabelMapFilter” that operate on label maps. These can be very efficient for relabling, selecting and other supported LabelMap operations.

1 Like