Skip to content

Commit 3c5946c

Browse files
authored
fix: Clean elements outside mask for multiple otsu method (#1319)
Fix problem from image: ![IMG_20251015_011543.jpg](https://github.com/user-attachments/assets/f29d5b68-24b9-4273-a26e-18346485628e) ## Summary by Sourcery Bug Fixes: - Zero out segmentation voxels outside the mask when a mask is provided <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Segmentation now properly respects masks: background/invalid regions are excluded from size calculations and threshold annotations, resulting in accurate component sizes and per-component thresholds when a mask is applied. * **Chores** * Project configuration updated to list an additional tool/library; this is a metadata change with no direct user-facing impact. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 11c3869 commit 3c5946c

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

.github/project_dict.pws

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ sdk
2424
PR
2525
dependabot
2626
cooldown
27+
otsu

package/PartSegCore/segmentation/restartable_segmentation_algorithms.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,8 @@ def calculation_run(self, report_fun):
642642
self.new_parameters.valley,
643643
)
644644
res = SimpleITK.GetArrayFromImage(res)
645+
if self.mask is not None:
646+
res[self.mask == 0] = 0
645647
self._sizes_array = np.bincount(res.flat)[1:]
646648
self.threshold_info = []
647649
annotations = {}

0 commit comments

Comments
 (0)