# BinaryImageToShapeLabelMapFilter vs. LabelImageToShapeLabelMapFilter

**URL:** https://discourse.itk.org/t/binaryimagetoshapelabelmapfilter-vs-labelimagetoshapelabelmapfilter/1214
**Category:** Beginner Questions
**Created:** [August 20, 2018, 9:03pm UTC](https://discourse.itk.org/t/binaryimagetoshapelabelmapfilter-vs-labelimagetoshapelabelmapfilter/1214 "2018-08-20T21:03:34Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Fijoy\_Vadakkumpadan](https://discourse.itk.org/user_avatar/discourse.itk.org/fijoy_vadakkumpadan/32/1287_2.png) [@Fijoy\_Vadakkumpadan](https://discourse.itk.org/u/Fijoy_Vadakkumpadan)
#### Post date: [August 20, 2018, 9:03pm UTC](https://discourse.itk.org/t/binaryimagetoshapelabelmapfilter-vs-labelimagetoshapelabelmapfilter/1214/1 "2018-08-20T21:03:35Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![tim-evain](https://discourse.itk.org/user_avatar/discourse.itk.org/tim-evain/32/220_2.png) [@tim-evain](https://discourse.itk.org/u/tim-evain)
#### Post date: [August 21, 2018, 10:08am UTC](https://discourse.itk.org/t/binaryimagetoshapelabelmapfilter-vs-labelimagetoshapelabelmapfilter/1214/2 "2018-08-21T10:08:34Z")

</div>

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,

---

<div class="post-metadata">

### Author: ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)
#### Post date: [August 21, 2018, 1:24pm UTC](https://discourse.itk.org/t/binaryimagetoshapelabelmapfilter-vs-labelimagetoshapelabelmapfilter/1214/3 "2018-08-21T13:24:08Z")

</div>

Hello Fijoy,

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

> <https://github.com/InsightSoftwareConsortium/ITK/blob/764472b182f764512549f6481a343c396ce28cee/Modules/Filtering/LabelMap/include/itkBinaryImageToShapeLabelMapFilter.hxx#L66>

  

> <https://github.com/InsightSoftwareConsortium/ITK/blob/764472b182f764512549f6481a343c396ce28cee/Modules/Filtering/LabelMap/include/itkLabelImageToShapeLabelMapFilter.hxx#L64>

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.
