ImageResampler#

class zrad.preprocessing.interpolation.ImageResampler(resolution, method='linear', intensity_rounding=None)[source]#

Resample an image or RoiData.image onto a target voxel grid.

Image resampling standardizes voxel spacing before downstream processing. Intensities are interpolated on a grid with the requested physical resolution while preserving image orientation and updating the origin.

Parameters:
  • resolution (float or sequence of float) – Target voxel spacing in millimetres. A single positive value is applied to all three axes. A sequence must contain three positive values in (x, y, z) order.

  • method (str, optional) – Interpolation method used for image intensities. Supported values are "linear", "nearest_neighbor", "bspline", and "gaussian" including common aliases such as "trilinear" and "nn". The default is "linear".

  • intensity_rounding ({None, "nearest_integer"}, optional) – Optional post-processing for resampled intensities. Use "nearest_integer" to round values to the nearest integer and cast them to int16. The default keeps floating-point intensities.

Methods

apply(data)

Return a resampled image or ROI data with a resampled image.

get_params()

Return image-resampling parameters mapped to their configured values.

ImageResampler.apply(data)[source]#

Return a resampled image or ROI data with a resampled image.

Parameters:

data (Image or RoiData) – Image to resample. If RoiData is supplied, only data.image is resampled and intensity-derived fields are cleared.

Returns:

resampled – Resampled image, or ROI data with a resampled image field.

Return type:

Image or RoiData

ImageResampler.get_params()[source]#

Return image-resampling parameters mapped to their configured values.

Returns:

params – Dictionary containing resolution, method, and intensity_rounding.

Return type:

dict