Skip to content

Add voxel-edge contour mode - #141

Merged
qurit-frizi merged 1 commit into
mainfrom
add-voxel-edge-contours
Aug 14, 2026
Merged

Add voxel-edge contour mode#141
qurit-frizi merged 1 commit into
mainfrom
add-voxel-edge-contours

Conversation

@carluri

@carluri carluri commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds an opt-in voxel-edge contour strategy when converting binary masks to
RTSTRUCT contours.

rtstruct.add_roi(mask=mask, name="Kidney", contour_mode="voxel_edge")

The existing voxel_center behavior remains the default for backward
compatibility.

Why

The existing OpenCV contour extraction traces through the centres of boundary
voxels. When another application rasterizes those polygons using voxel-centre
inclusion, the outermost voxel ring can be lost and the resulting ROI appears
inset by half a voxel.

The new mode traces the boundary of the union of foreground voxel squares at
half-integer pixel coordinates. This places contours on the outer voxel edges
and allows consumers using voxel-centre inclusion to reproduce the complete
mask footprint.

Changes

  • Add contour_mode to RTStruct.add_roi and ROIData.
  • Preserve contour_mode="voxel_center" as the default.
  • Add native voxel_edge polygon tracing with collinear-point removal.
  • Validate unsupported contour modes.
  • Document the new API in the README.
  • Test single voxels, rectangles, holes, diagonal contact, invalid modes, and
    patient-space placement.

Validation

  • pytest -q
  • 45 passed
  • 72 existing pydicom deprecation warnings

@qurit-frizi
qurit-frizi marked this pull request as ready for review August 14, 2026 23:39
@qurit-frizi

Copy link
Copy Markdown
Collaborator

Approved.

@qurit-frizi
qurit-frizi merged commit 9a23009 into main Aug 14, 2026
4 checks passed
@carluri
carluri deleted the add-voxel-edge-contours branch August 15, 2026 00:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants