MultiLabelSTAPLEImageFilter introduce new label value

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

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, 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 (133.8 KB)

This is a bug in ITK, see bug fix details on github.

2 Likes

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

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

2 Likes