Skip to content

Commit 0cb6436

Browse files
authored
Merge pull request #455 from zivy/bugSurfaceHausdorffDistance
BUG: issue when segmentation touched the image border
2 parents 9c41a5a + 8739a8c commit 0cb6436

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Python/34_Segmentation_Evaluation.ipynb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,18 @@
490490
" \"\"\"\n",
491491
" Compute symmetric surface distances and take the maximum.\n",
492492
" \"\"\"\n",
493+
" # When the segmentation touches the image border we have corner case for the computation.\n",
494+
" # The surface/contour computation yields a surface that is outside the image bounds and\n",
495+
" # is thus not included in the computation. This is not correct for our use case. By padding\n",
496+
" # the segmentations we ensure that we obtain the surface as expected and the distance computations\n",
497+
" # are correct. Padding has no effect on results if the original segmentations did not touch the image\n",
498+
" # border.\n",
499+
" dim = reference_segmentation.GetDimension()\n",
500+
" reference_segmentation = sitk.ConstantPad(\n",
501+
" reference_segmentation, [1] * dim, [1] * dim\n",
502+
" )\n",
503+
" seg = sitk.ConstantPad(seg, [1] * dim, [1] * dim)\n",
504+
"\n",
493505
" reference_surface = sitk.LabelContour(reference_segmentation)\n",
494506
" reference_distance_map = sitk.Abs(\n",
495507
" sitk.SignedMaurerDistanceMap(\n",

0 commit comments

Comments
 (0)