ENH: Add fractional labelmap conversion rules to segmentations
This commit adds two new conversion rules to the segmentation module.
- Closed surface to fractional labelmap
- Fractional labelmap to closed surface
The fractional labelmap is generated from the closed surface representation by creating 216 binary labelmaps with shifted origins. Summing the binary labelmaps results in an image where each voxel indicates the fraction of the voxel that is filled by the structure (with a range of 217 possible values). The shifted positions allow each voxel to be evenly sampled at 216 different points.
The closed surface is generated from the fractional labelmap by running a marching squares algorithm on the specified fractional threshold (between 0.0 and 1.0, 0.5 by default).
Each fractional labelmap contains 3 data fields: "ScalarRange" - vtkDoubleArray [2] = { minimumValue, maximumValue } "ThresholdValue" - vtkDoubleArray [1] = {thresholdValue} "InterpolationType" - vtkIntArray [1] = VTK_CUBIC_INTERPOLATION, VTK_LINEAR_INTERPOLATION, VTK_NEAREST_INTERPOLATION
Scalar range is used for visualization in vtkMRMLSegmentationsDisplayableManager2D and can be used to convert the voxel value into a fractional floating point for algorithms such as DVH calculation in SlicerRT. Threshold value and InterpolationType are currently only used for visualization.
Segmentation data probe has been modified to display fractional voxel values. Fractional interpolation for vtkOrientedImageDataResample::TransformOrientedImage and vtkOrientedImageDataResample::ResampleOrientedImageToReferenceOrientedImage is now functional. vtkBinaryLabelmapToClosedSurfaceConversionRule::IsLabelmapPaddingNecessary has been modified to use any scalar type.
This image shows the results of the closed surface to fractional labelmap conversion, as well as the reverse. The closed surface to fractional labelmap conversion took ~10s on my machine.