SliceDistanceTransform¶
-
MLModule
¶ author MeVis Medical Solutions AG
package MeVisLab/Standard
dll SliceDistanceTransform
definition SliceDistanceTransform.def see also CSOVoxelizeContours
,VoxelizeCSO
,SignedEuclideanDistanceTransform
keywords shape
,based
,interpolation
,euclidean
,chamfer
,voxelize
,CSO
,contour
Purpose¶
The module SliceDistanceTransform
computes the distance from each voxel midpoint to the border of an object defined by a mask or by contours (CSOs) on slices where the object is defined.
Additionally, the module SliceDistanceTransform
can optionally interpolate those distances on slices between the slices where the object is defined.
Usage¶
To estimate the shape of an object from sparsely spaced slices using ‘Shape Based Interpolation,’ as described in the referenced paper, select a Distance Mode
based on the available input and choose Interpolate Slices
.
The module SliceDistanceTransform
can also be utilized to create a smooth surface from CSOs, such as contours read from an RT Struct.
Disable Interpolate Slices
in this case and use Distance Mode
Contours Chamfer or Contours Exact.
Connect a WEMIsoSurface
to output0
to create a WEM from the contours.
The WEMIsoSurface
should set WEMIsoSurface.useMinValue
to TRUE, and set WEMIsoSurface.useMaxValue
to FALSE, and use a small negative value as WEMIsoSurface.isoMaxValue
in order to generate a surface with distance close to 0 to the contours or the input mask borders:

Details¶
The algorithm is based on ‘method 5’ (with linear between-slice interpolation) described in:
G. Herman et al: Shape-based Interpolation, IEEE Computer Graphics&Applications, vol. 12 no. 3 p.69-79.
The original algorithm, as described in the paper, initializes the pixels adjacent to the object border with static distance values and subsequently distributes these values to the remaining pixels of the slice using a fast two-phase chamfering algorithm. This approach is applied when using Distance Mode
Input Image Mask.
If using Distance Mode
Contours Chamfer, this module initializes the border pixels with the exact distance to the contours instead of using initial static integer distance values on a binary mask. This yields higher distance precision, especially near the contours.
The chamfering process remains the same, except when Distance Mode
Contours Exact is checked. In this case, the chamfering process is skipped, and the exact distance to the contours is calculated for all pixels of slices where the contours are defined. However, this process takes significantly longer.
Distances are calculated in world space, in contrast to the algorithm presented in the referenced paper.
The computed distances are signed, with distances outside the contours being positive and distances inside the contours being negative.
For the Distance Mode
Contours Chamfer, the given contours are internally voxelized on the slices where they are defined, equivalent to using CSOVoxelizeContours
in XOR mode, with BorderHandling set to Midpoint.
For both Distance Mode
Contours Chamfer and Contours Exact, there is no need to voxelize the contours into the input image beforehand, as the content of the input image is ignored in these modes.
Time points are not handled by SliceDistanceTransform
. Please use a combination of SubImage
and CSOFilter
to manage the time points correctly. The module SliceDistanceTransform
outputs an image with only one time point and treats the CSOs of all given time points as if they had the same time point.
Input Fields¶
input0¶
-
name:
input0
, type:
Image
¶ The input image is used solely as a binary mask or as a reference grid, respectively.
For
Distance Mode
Input Image Mask, the image is interpreted as a binary mask, where voxels with a value of 0 are considered background, and all other values are regarded as foreground.For both Contours Chamfer and Contours Exact, only the image’s extent, voxel size, and world-to-voxel matrix are utilized; the actual voxel values are not used.
inCSOList¶
-
name:
inCSOList
, type:
CSOList(MLBase)
¶ The input CSOList; this input is not used in
Distance Mode
Input Image Mask.The CSOs must lie in the axial voxel plane of the input image and must be closed.
CSOs above and below the input image in the z-direction (in voxel space) are not considered. CSOs beside the input image (in the x/y direction in voxel space) are only considered in
Distance Mode
Contours Exact.For accessing this object via scripting see the Scripting Reference:MLCSOListWrapper
.
Output Fields¶
Parameter Fields¶
Field Index¶
Clear : Trigger |
Distance Mode : Enum |
Interpolate Slices : Bool |
Update : Trigger |
Update Mode : Enum |
Value for non-interpolated slices : Float |
Visible Fields¶
Update Mode¶
-
name:
updateMode
, type:
Enum
, default:
Clear
¶ Defines the update behavior of the module, reacting to changes of any input or parameter field (except
Update Mode
itself).
Values:
Title | Name | Description |
---|---|---|
Off | Off | The module does not change its output. |
Clear | Clear | The module clears its output. |
Update | Update | The module computes anew. |
Interpolate Slices¶
-
name:
interpolateSlices
, type:
Bool
, default:
FALSE
¶ If checked, the module interpolates the distances on the slices between those where contours are defined.
Otherwise, only the distances on the slices where contours or masks are defined are computed.
Value for non-interpolated slices¶
-
name:
valueForNonInterpolatedSlices
, type:
Float
, default:
0
¶ Sets a distance value that is written into voxels on slices that are not interpolated.
These slices are those between the slices where contours are defined if the option
Interpolate Slices
is off; in any case, all slices above the first and below the last slices where contours are defined.
Distance Mode¶
-
name:
distanceMode
, type:
Enum
, default:
InputImageMask
¶ Defines the algorithm used for distance calculation.
Values:
Title | Name | Description |
---|---|---|
Input Image Mask | InputImageMask | Calculates distances to the border between background (voxel value equals 0) and foreground voxels (voxel value not equal to 0) in the input mask image on slices where the mask is defined, using a fast two-phase chamfering algorithm. If this mode is used, the input contours are not considered at all. |
Contours Chamfer | ContoursChamfer | Calculates exact distances to the input contours for voxels ‘touching’ the contours and distributes these distances on slices where the contours are defined, using a fast two-phase chamfering algorithm. If this mode is used, the content of the input image mask is not considered at all. |
Contours Exact | ContoursExact | Calculates exact distances to the input contours for all voxels on slices where the contours are defined. If this mode is used, the content of the input image mask is not considered at all. |