# MultiLabelSTAPLEImageFilter introduce new label value

**URL:** https://discourse.itk.org/t/multilabelstapleimagefilter-introduce-new-label-value/2593
**Category:** Beginner Questions
**Tags:** simpleitk
**Created:** [January 8, 2020, 1:00pm UTC](https://discourse.itk.org/t/multilabelstapleimagefilter-introduce-new-label-value/2593 "2020-01-08T13:00:10Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![hubutui](https://discourse.itk.org/user_avatar/discourse.itk.org/hubutui/32/716_2.png) [@hubutui](https://discourse.itk.org/u/hubutui)
#### Post date: [January 8, 2020, 1:00pm UTC](https://discourse.itk.org/t/multilabelstapleimagefilter-introduce-new-label-value/2593/1 "2020-01-08T13:00:10Z")

</div>

I’m using `MultiLabelSTAPLEImageFilter` to combine several annotations. However, this filter introduce new label value. Here is my script:

```python
import SimpleITK as sitk
import numpy as np
import os
import os.path as osp

if __name__ == ' __main__':
    dirname = 'testmasks'
    imgs = [sitk.ReadImage(osp.join(dirname, item)) for item in os.listdir(dirname)]
    for img in imgs:
        print(np.unique(sitk.GetArrayFromImage(img)))
    filter = sitk.MultiLabelSTAPLEImageFilter()
    filter.SetLabelForUndecidedPixels(255)
    result = filter.Execute(*imgs)
    print(np.unique(sitk.GetArrayFromImage(result)))

```

The label value range from 0 to 6, but I got 7 in the result. According to the [doc](https://itk.org/SimpleITKDoxygen/html/classitk_1_1simple_1_1MultiLabelSTAPLEImageFilter.html), this filter set label for undecided pixel to the maximum of the label value plus 1. It seems that the `SetLabelForUndecidedPixels` method not working?

I’m using SimpleITK 1.2.4. The files are in attachement. [testmasks.tar.gz](https://discourse.itk.org/uploads/short-url/2gksrGk9973KuHPEDfuC4iDx2hN.gz) (133.8 KB)

---

<div class="post-metadata">

### Author: ![zivy](https://discourse.itk.org/user_avatar/discourse.itk.org/zivy/32/1726_2.png) [@zivy](https://discourse.itk.org/u/zivy)
#### Post date: [January 13, 2020, 4:23pm UTC](https://discourse.itk.org/t/multilabelstapleimagefilter-introduce-new-label-value/2593/2 "2020-01-13T16:23:15Z")

</div>

This is a bug in ITK, [see bug fix details on github](https://github.com/SimpleITK/SimpleITK/issues/943).

---

<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: [January 14, 2020, 2:34pm UTC](https://discourse.itk.org/t/multilabelstapleimagefilter-introduce-new-label-value/2593/3 "2020-01-14T14:34:01Z")

</div>

The issue has been addressed in ITK, and SimpleITK has been updated. The patch made it into the latest packaging for SimpleITK. Please see here for the instruction to download:  
[https://simpleitk.readthedocs.io/en/master/installation.html#latest-binaries](https://simpleitk.readthedocs.io/en/master/installation.html#latest-binaries)

Thank you for the excellent post with concise code and test data to reproduce the issue.
