thresholding a mask

There are not a shortage of ways to do this in ITK.

A new option with ITKv5 is to use the BinaryGeneratorImageFilter to us a white a little lambda function to place run inside a filter:

I haven’t compiled this code, but it should be something like this:

using FilterType = itk::BinaryGeneratorImageFilter<InputImageType, MaskImageType OutputImageType>;
auto filter = FilterType::New();
filter->SetFunctor([](const InputPixelType &p1, const MaskPixelType &mask)->OutputPixelType
 { return mask!=1 || p1 > threshold; });
1 Like