InsightSoftwareConsortium / ITK

Insight Toolkit (ITK) -- Official Repository. ITK builds on a proven, spatially-oriented architecture for processing, segmentation, and registration of scientific images in two, three, or more dimensions.
https://itk.org
Apache License 2.0
1.37k stars 660 forks source link

ENH: Optionally limit an ImageMask to a specific pixel value #4617

Closed aylward closed 2 months ago

aylward commented 2 months ago

Nominally an ImageMaskSpatialObject considers any non-zero pixel to indicate that the object is present at that point.

With this change, it is possible to specify a MaskValue and to enable the use of that MaskValue (via the UseMaskValue functions) so that a specific pixel value is needed to indicate the presence of that object.

This is particularly useful when a single mask image defines multiple objects via different values. That single image can be assigned to multiple ImageMaskSpatialObjects, each using a different MaskValue. This reduces memory requirements, etc.

A new set of tests were added to confirm proper function.

Default behaviour is unchanged.