Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 19 additions & 25 deletions Python/05_Results_Visualization.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1085,33 +1085,27 @@
" for c in colors:\n",
" if c == [0, 0, 0]:\n",
" raise ValueError(\"Colors include black [0,0,0], not allowed\")\n",
" empty_image = image * 0\n",
" overlay_boundaries = [\n",
" sitk.LabelMapContourOverlay(\n",
" sitk.Cast(seg, sitk.sitkLabelUInt8),\n",
" empty_image,\n",
" opacity=1,\n",
" contourThickness=thickness,\n",
" dilationRadius=dilation_radius,\n",
" colormap=color,\n",
" )\n",
" for seg, color in zip(binary_segmentations, colors)\n",
"\n",
" # Merge into a single label map (MergeLabelMapFilter's default KEEP method\n",
" # keeps each input's region distinct even though they all use label 1),\n",
" # so LabelMapContourOverlay handles overlapping contours itself in a\n",
" # single pass instead of manually compositing per-segmentation results.\n",
" merged_labels = sitk.MergeLabelMap(\n",
" [sitk.Cast(seg, sitk.sitkLabelUInt8) for seg in binary_segmentations],\n",
" sitk.MergeLabelMapFilter.Keep,\n",
" )\n",
" flat_colormap = [\n",
" channel for color in colors[: len(binary_segmentations)] for channel in color\n",
" ]\n",
"\n",
" current_image = sitk.Compose([image] * 3)\n",
" for o_image in overlay_boundaries:\n",
" current_mask = (\n",
" sitk.NaryAdd(\n",
" [\n",
" sitk.VectorIndexSelectionCast(o_image, 0),\n",
" sitk.VectorIndexSelectionCast(o_image, 1),\n",
" sitk.VectorIndexSelectionCast(o_image, 2),\n",
" ]\n",
" )\n",
" == 0\n",
" )\n",
" current_image = mask_image_multiply(current_mask, current_image) + o_image\n",
" return current_image\n",
" return sitk.LabelMapContourOverlay(\n",
" merged_labels,\n",
" image,\n",
" opacity=1,\n",
" contourThickness=thickness,\n",
" dilationRadius=dilation_radius,\n",
" colormap=flat_colormap,\n",
" )\n",
"\n",
"\n",
"binary_segmentations = [\n",
Expand Down
2 changes: 2 additions & 0 deletions tests/additional_dictionary.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
LabelMapContourOverlay
MergeLabelMapFilter's
ipympl
ACM
ANTSNeighborhoodCorrelation
Expand Down
Loading