Skip to content

Conversation

fizxmike
Copy link
Member

@fizxmike fizxmike commented Jul 1, 2025

Implemented fast structure mask creation leveraging OpenCV's cv2.fillpoly(...) with contours from each slice read from ESAPI's Structure.GetContoursOnImagePlane(...). Boolean output only, when a lower slice (z) resolution is requested, the mask is generated based on the contours on the original CT slice intersected by the mid-plane of the lower resolution (requested) slice.

Example usage (CT grid):
mask_ct_res = plan.StructureSet.np_mask_for_structure_fast(structure, plan.StructureSet.Image)

Mask for dose grid:
mask_dose_res = plan.StructureSet.np_mask_for_structure_fast(structure, plan.Dose)

Implemented fast structure mask creation leveraging OpenCV's fillpoly(...) with contours from each slice coming from ESAPI's .
This gets around the limitation of OpenCV supporting only integer values for coordinates on the image plane.
@fizxmike
Copy link
Member Author

fizxmike commented Jul 1, 2025

The super sampling implementation increases the accuracy significantly. I chose 8 as the super sampling factor default after some empirical experimentation comparing a fairly complex mask slice between the original PyESAPI method and this new/fast/approximate method. Maybe 6 could work too, but a better study would involve impact on DVH.

image

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.

1 participant