BinaryImageToShapeLabelMapFilter vs. LabelImageToShapeLabelMapFilter

Hello,

What’s the best filter to use to compute size/shape attributes of all connected components in an image?

Looking at the docs, I see two filters, LabelImageToShapeLabelMapFilter and BinaryImageToShapeLabelMapFilter, for this purpose. But the latter seems to be a combination of the former and the ConnectedComponentImageFilter. If so, is there any other difference between the 2 filters? Specifically, do both filters give the user access to the same set of size/shape attributes of each connected component?

Thanks.

Hi Fijoy,

If I recall correctly the only difference is that the Binary one will treat all non-zero as the same “level”, i.e. if you have neighboring components of different non-zero values, they will be merged. Otherwise, ShapeLabelObjects are computed in both case, so the attributes will be strictly the same.

HTH,

1 Like

Hello Fijoy,

If you look a the source code for the two filters:


You will see they are both composite filters. Which means the filter is just composed of other filters connected. The BinaryImageToShapLabelMapFilter is composed of the BinaryImageToLabelMapFilter->ShapeLabelMapFilter, while the LabelImageToShapeLabelMapFilter is make of the LabelImageToLabelMapFilter->ShapeLabelMapFilter. The second filter is the one which computes the statistics on a LabelMap, so that step will be the same between the two filters you mention.

2 Likes