Skip to content

Commit 8739a8c

Browse files
committed
BUG: issue when segmentation touched the image border
The surface computation used in the surface_hausdorff_distance yielded incorrect results when the segmentation was touching the image border. In this case the surface is outside the image extent, so when voxelized the expected voxels were not marked as surface. By padding the image we resolve the problem. resolves #453
1 parent 9c41a5a commit 8739a8c

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)