Purpose

The module SliceDistanceTransform computes the distance of each voxel midpoint to the border of an object defined by a mask or by contours (CSOs) on slices where the object is defined.

The module SliceDistanceTransform can also optionally interpolate those distances on slices in 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 depending on the available input and choose Should Interpolate Slices.

SliceDistanceTransform can also be used to create a smooth surface from CSOs, e.g., contours read from an RT Struct. Disable Should 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:

../../../Projects/SliceDistanceTransform/Modules/mhelp/Images/Screenshots/WEMIsoSurfaceParameters.png

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 next to the object border with static distance values and subsequently distributes them 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. When using Distance Mode Contours Chamfer this modules 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 a 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. This takes much longer, though.

Distances are calculated in world space, in contrast to the algorithm described in the referenced paper.

The computed distances are signed, where the distances outside the contours are positive and the distances inside the contours are 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 and with the 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. 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 handle the time points correctly. The module SliceDistanceTransform outputs an image with only one time point and considers the CSOs of all given time points as if they had the same time point.

Windows

Default Panel

../../../Projects/SliceDistanceTransform/Modules/mhelp/Images/Screenshots/SliceDistanceTransform._default.png

Input Fields

input0

name: input0, type: Image

Input image used as a binary mask or as a reference grid only, respectively.

For Distance Mode Input Image Mask the image is interpreted as a binary mask. Voxels with a value of 0 are considered as background, all other values are considered as foreground.

For both Contours Chamfer and Contours Exact, only the image’s extent, the voxel size, and the world-to-voxel-matrix are used, the actual voxel values are not used.

inCSOList

name: inCSOList, type: CSOList(MLBase)

Input CSOList, not used in Distance Mode Input Image Mask.

The CSOs must lie in axial voxel plane of the input image and must be closed.

CSOs above and below the input image in z-direction (in voxel space) are not considered. CSOs beside the input image (in 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

output0

name: output0, type: Image

Distance image, where the voxel values represent the distances to the given contours or the mask border on a slice. Voxels inside the contours have a negative sign, voxels outside the contours have a positive sign.

Parameter Fields

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.

Should Interpolate Slices

name: interpolateSlices, type: Bool, default: FALSE

If checked, the module interpolates the distances on the slices between the slices 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.

Those slices are the slices in between the slices where contours are defined if the option Should Interpolate Slices is off, in any case all slices above and below the first / last slice 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 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.

Update

name: update, type: Trigger

If pressed, the module computes anew.

Clear

name: clear, type: Trigger

If pressed, the module clears and invalidates its output image.