Purpose

The module ImageResample resizes/re-samples and image with integer resampling factors.

All data types can be re-sampled, i.e., int, double, vec2, mat3, etc.

Usage

For unsigned data types (e.g., uint16) and for data types with limited range (e.g., int8), it is strongly suggested to choose a non-ringing anti-aliasing filter to avoid overflow and underflow effects.

Details

Separate algorithms are implemented for Nearest neighbor resampling, and resampling using an anti-aliasing filter.

The Nearest neighbor resampling is significantly faster, but aliasing effects will occur if the image or signal is not band-limited prior to the resampling. This is the purpose of the anti-aliasing filter. Below, the kernels for a few filters for a downsampling of a factor 2 are shown in the left column and the Fourier transform of the kernel in the right column. The ideal anti-aliasing filter is shown in solid black. The Linear filter is the fastest to apply but the Lanczos 3 gives a better anti-aliasing protection. It is important to note that the Linear and the Cubic B-Spline filters have all positive coefficients, whereas the Lanczos filters also have negative coefficients. This means that the latter filters will introduce ringing effects at sharp edges. This may be a problem if the input image is of an unsigned type (e.g., uint16) or has a limited range (e.g., int8) because the filtered/re-sampled image may adopt values outside the numeric range due to the ringing. For example, values below zero may be produced for uint16 input, causing a numerical underflow in the output. This will not happen for the non-ringing Linear and Cubic B-Spline filters. It is therefore strongly recommended to choose a non-ringing filter for these data types. A Nearest neighbor resampling is safe for all data types.

../../../Projects/MLImageResample/Modules/mhelp/Images/filters.png

To apply an anti-aliasing filter, the input image must be padded to calculate voxels at the border. There are two options: either the input image can be padded with a user-defined value or the border of the input image is extended. The latter approach is computationally more expensive.

Windows

Default Panel

../../../Projects/MLImageResample/Modules/mhelp/Images/Screenshots/ImageResample._default.png

Input Fields

input0

name: input0, type: Image

Connect the ML image to be resampled here. Extended voxel types are also such as vec2, mat3, etc.

Output Fields

output0

name: output0, type: Image

Provides the resampled ML image.

Parameter Fields

Field Index

Auto update: Bool Update: Trigger
Border handling: Enum X: Integer
C: Integer Y: Integer
Fill value: Double Z: Integer
Filter: Enum  
Operation: Enum  
T: Integer  
U: Integer  

Visible Fields

Operation

name: resamplingOperation, type: Enum, default: Downsampling

Defines the operation that should be performed on the input image.

Values:

Title Name Description
Downsampling Downsampling Results in an image with larger but less voxels.
Upsampling Upsampling Results in an image with smaller but more voxels.

X

name: xResample, type: Integer, default: 1

Sets the integer re-sampling factor for the x-direction.

Y

name: yResample, type: Integer, default: 1

Sets the integer re-sampling factor for the y-direction.

Z

name: zResample, type: Integer, default: 1

Sets the integer re-sampling factor for the z-direction.

C

name: cResample, type: Integer, default: 1

Sets the integer re-sampling factor for the c-direction.

T

name: tResample, type: Integer, default: 1

Sets the integer re-sampling factor for the t-direction.

U

name: uResample, type: Integer, default: 1

Sets the integer re-sampling factor for the u-direction.

Filter

name: antiAliasingFilter, type: Enum, default: Nearest neighbor

Defines the filter to apply, i.e., how the output voxels are selected / computed.

For Nearest Neighbor mode, note that if the center of a target voxel lies exactly on the boundary between two source voxels, the value will be taken from the one with the lower coordinate value (i.e. the left one in 1D).

Values:

Title Name
Nearest neighbor Nearest neighbor
Linear Linear
Cubic B-Spline Cubic B-Spline
Lanczos 2 Lanczos 2
Lanczos 3 Lanczos 3

Border handling

name: borderHandling, type: Enum, default: Fill

Sets the border handling for the anti-aliasing filter.

Values:

Title Name Description
Fill Fill The border is filled with the Fill value.
Extend border Extend border The border voxels are copies.

Fill value

name: borderFillValue, type: Double, default: 0

Sets a fill value for border handling.

Update

name: updateButton, type: Trigger

If pressed, the module computes anew.

Auto update

name: autoUpdate, type: Bool, default: FALSE

If checked, the module computes anew on any parameter or input change.