Repository navigation
BUG: Fix LabelMapMaskImageFilter BackgroundValue cast through label type - #2629
Merged
blowekamp merged 1 commit intoJul 21, 2026
Merged
Conversation
blowekamp
force-pushed
the
fix_label_map_mask_background_value
branch
2 times, most recently
from
July 15, 2026 19:54
716c58b to
915a9d5
Compare
BackgroundValue was cast to the LabelMap pixel type (unsigned) instead of the feature image type, silently destroying negative values. Fix by adding output_image_type: InputImageType2 to the yaml. Adds a C++ regression test. Fixes SimpleITK#2625 (S16)
blowekamp
force-pushed
the
fix_label_map_mask_background_value
branch
from
July 20, 2026 20:20
915a9d5 to
ce3a532
Compare
blowekamp
marked this pull request as ready for review
July 21, 2026 13:10
dave3d
approved these changes
Jul 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes issue #2625 (S16):
BackgroundValueinLabelMapMaskImageFilterwas silently losing negative values due to a wrong cast.Root Cause
BackgroundValuewas declaredpixeltype: Output, but nooutput_image_typewas set in the YAML. The dual template's fallback assignsOutputImageType = InputImageType— the LabelMap type (unsigned integer). This caused thedoublebackground value to bestatic_castto the unsigned label pixel type before being forwarded to ITK, destroying any negative or non-integer value.Fix
Add
output_image_type: InputImageType2toLabelMapMaskImageFilter.yaml, makingOutputImageTypealias the feature image type as ITK's filter intends.Test
Added
BasicFilters.LabelMapMaskImageFilter_BackgroundValuePreservedinsitkBasicFiltersTests.cxx: runs the filter with a float feature image andBackgroundValue = -1000.0, asserts the output minimum is-1000.0.