ResampleAffine2d
Resamples a two-dimensional image by defining an oriented bounding box and a geometric transform.
Access to parameter description
This algorithm allows the resampling of an input image onto a user-defined image domain, and optionally apply a geometric transform on it.
The output image domain is defined by a non-axis aligned bounding box (nAABB). To represent the nAABB, we use an AABB (boundingBoxMin, boundingBoxMax) and a angle (boundingBoxAngle).
An additional transformation can be applied to each output voxel position to produce the final resampled image. Each output voxel intensity is extracted from the input with a user-defined interpolation.
For example, this algorithm can be used:
Access to parameter description
This algorithm allows the resampling of an input image onto a user-defined image domain, and optionally apply a geometric transform on it.
The output image domain is defined by a non-axis aligned bounding box (nAABB). To represent the nAABB, we use an AABB (boundingBoxMin, boundingBoxMax) and a angle (boundingBoxAngle).
An additional transformation can be applied to each output voxel position to produce the final resampled image. Each output voxel intensity is extracted from the input with a user-defined interpolation.
For example, this algorithm can be used:
- To extract a user-defined region of interest with a given pixel size (not necessary aligned with the input) from the input image.
- To generate a new image from a model image registered on reference image using the transform given by the AffineRegistration algorithm.
Function Syntax
This function returns outputImage.
// Function prototype
std::shared_ptr< iolink::ImageView > resampleAffine2d( std::shared_ptr< iolink::ImageView > inputImage, ResampleAffine2d::InterpolationType interpolationType, const iolink::Vector2d& boundingBoxMin, const iolink::Vector2d& boundingBoxMax, double boundingBoxAngle, ResampleAffine2d::SamplingMode samplingMode, const iolink::Vector2u32& imageDimensions, double paddingValue, const iolink::Matrix3d& transform, std::shared_ptr< iolink::ImageView > outputImage = nullptr );
This function returns outputImage.
// Function prototype. resample_affine_2d(input_image: idt.ImageType, interpolation_type: ResampleAffine2d.InterpolationType = ResampleAffine2d.InterpolationType.LINEAR, bounding_box_min: Union[Iterable[int], Iterable[float]] = [0, 0], bounding_box_max: Union[Iterable[int], Iterable[float]] = [1, 1], bounding_box_angle: float = 0, sampling_mode: ResampleAffine2d.SamplingMode = ResampleAffine2d.SamplingMode.AUTOMATIC, image_dimensions: Iterable[int] = [100, 100], padding_value: float = 0, transform: Union[idt.NDArrayAny, iolink.Matrix3d, iolink.Matrix3f] = _np.identity(3), output_image: idt.ImageType = None) -> idt.ImageType
This function returns outputImage.
// Function prototype. public static IOLink.ImageView ResampleAffine2d( IOLink.ImageView inputImage, ResampleAffine2d.InterpolationType interpolationType = ImageDev.ResampleAffine2d.InterpolationType.LINEAR, double[] boundingBoxMin = null, double[] boundingBoxMax = null, double boundingBoxAngle = 0, ResampleAffine2d.SamplingMode samplingMode = ImageDev.ResampleAffine2d.SamplingMode.AUTOMATIC, uint[] imageDimensions = null, double paddingValue = 0, IOLink.Matrix3d transform = null, IOLink.ImageView outputImage = null );
Class Syntax
Parameters
Parameter Name | Description | Type | Supported Values | Default Value | |||||
---|---|---|---|---|---|---|---|---|---|
![]() |
inputImage |
The input image to resample. It can have integer or floating point data type. | Image | Binary, Label, Grayscale or Multispectral | nullptr | ||||
![]() |
boundingBoxMin |
The minimum X, and Y coordinates of the box that defines the image domain after a rotation, in world coordinates. The output image domain corresponds to this axis-aligned bounding box, rotated at an angle defined by the boundingBoxAngle parameter. | Vector2d | Any value | {0.f, 0.f} | ||||
![]() |
boundingBoxMax |
The maximum X, and Y coordinates of the box that defines the image domain after a rotation, in world coordinates. The output image domain corresponds to this axis-aligned bounding box, rotated at an angle defined by the boundingBoxAngle parameter. | Vector2d | Any value | {1.f, 1.f} | ||||
![]() |
boundingBoxAngle |
The rotation to apply to the box defined by boundingBoxMin and boundingBoxMax in order to define the domain of the output image. | Float64 | Any value | 0 | ||||
![]() |
samplingMode |
The way to determine the resolution of the output image.
|
Enumeration | AUTOMATIC | |||||
![]() |
imageDimensions |
The size in pixels of the output image in each axis direction. If the samplingMode parameter is set to AUTOMATIC, this parameter is ignored. | Vector2u32 | != 0 | {100, 100} | ||||
![]() |
interpolationType |
The method used to calculate the intensity of each pixel in the result image.
|
Enumeration | LINEAR | |||||
![]() |
paddingValue |
Specifies the output value if an output pixel position is outside the bounding box of the input image. | Float64 | Any value | 0 | ||||
![]() |
transform |
The geometric transformation applied to the input image before interpolation. It is represented by a 3x3 matrix. It is important to note that this transformation is the inverse transformation, which means that it maps a point from the output domain to the input domain. | Matrix3d | IDENTITY | |||||
![]() |
outputImage |
The output image. Its dimensions are either defined by the imageDimensions parameter, if the samplingMode parameter is MANUAL, or automatically computed to match the user-defined bounding box with a resolution close to that of the input image. Its calibration is automatically adapted. Its type and interpretation are the same as the input image. | Image | nullptr |
Parameter Name | Description | Type | Supported Values | Default Value | |||||
---|---|---|---|---|---|---|---|---|---|
![]() |
input_image |
The input image to resample. It can have integer or floating point data type. | image | Binary, Label, Grayscale or Multispectral | None | ||||
![]() |
bounding_box_min |
The minimum X, and Y coordinates of the box that defines the image domain after a rotation, in world coordinates. The output image domain corresponds to this axis-aligned bounding box, rotated at an angle defined by the boundingBoxAngle parameter. | vector2d | Any value | [0, 0] | ||||
![]() |
bounding_box_max |
The maximum X, and Y coordinates of the box that defines the image domain after a rotation, in world coordinates. The output image domain corresponds to this axis-aligned bounding box, rotated at an angle defined by the boundingBoxAngle parameter. | vector2d | Any value | [1, 1] | ||||
![]() |
bounding_box_angle |
The rotation to apply to the box defined by boundingBoxMin and boundingBoxMax in order to define the domain of the output image. | float64 | Any value | 0 | ||||
![]() |
sampling_mode |
The way to determine the resolution of the output image.
|
enumeration | AUTOMATIC | |||||
![]() |
image_dimensions |
The size in pixels of the output image in each axis direction. If the samplingMode parameter is set to AUTOMATIC, this parameter is ignored. | vector2u32 | != 0 | [100, 100] | ||||
![]() |
interpolation_type |
The method used to calculate the intensity of each pixel in the result image.
|
enumeration | LINEAR | |||||
![]() |
padding_value |
Specifies the output value if an output pixel position is outside the bounding box of the input image. | float64 | Any value | 0 | ||||
![]() |
transform |
The geometric transformation applied to the input image before interpolation. It is represented by a 3x3 matrix. It is important to note that this transformation is the inverse transformation, which means that it maps a point from the output domain to the input domain. | matrix | _np.identity(3) | |||||
![]() |
output_image |
The output image. Its dimensions are either defined by the imageDimensions parameter, if the samplingMode parameter is MANUAL, or automatically computed to match the user-defined bounding box with a resolution close to that of the input image. Its calibration is automatically adapted. Its type and interpretation are the same as the input image. | image | None |
Parameter Name | Description | Type | Supported Values | Default Value | |||||
---|---|---|---|---|---|---|---|---|---|
![]() |
inputImage |
The input image to resample. It can have integer or floating point data type. | Image | Binary, Label, Grayscale or Multispectral | null | ||||
![]() |
boundingBoxMin |
The minimum X, and Y coordinates of the box that defines the image domain after a rotation, in world coordinates. The output image domain corresponds to this axis-aligned bounding box, rotated at an angle defined by the boundingBoxAngle parameter. | Vector2d | Any value | {0f, 0f} | ||||
![]() |
boundingBoxMax |
The maximum X, and Y coordinates of the box that defines the image domain after a rotation, in world coordinates. The output image domain corresponds to this axis-aligned bounding box, rotated at an angle defined by the boundingBoxAngle parameter. | Vector2d | Any value | {1f, 1f} | ||||
![]() |
boundingBoxAngle |
The rotation to apply to the box defined by boundingBoxMin and boundingBoxMax in order to define the domain of the output image. | Float64 | Any value | 0 | ||||
![]() |
samplingMode |
The way to determine the resolution of the output image.
|
Enumeration | AUTOMATIC | |||||
![]() |
imageDimensions |
The size in pixels of the output image in each axis direction. If the samplingMode parameter is set to AUTOMATIC, this parameter is ignored. | Vector2u32 | != 0 | {100, 100} | ||||
![]() |
interpolationType |
The method used to calculate the intensity of each pixel in the result image.
|
Enumeration | LINEAR | |||||
![]() |
paddingValue |
Specifies the output value if an output pixel position is outside the bounding box of the input image. | Float64 | Any value | 0 | ||||
![]() |
transform |
The geometric transformation applied to the input image before interpolation. It is represented by a 3x3 matrix. It is important to note that this transformation is the inverse transformation, which means that it maps a point from the output domain to the input domain. | Matrix3d | IDENTITY | |||||
![]() |
outputImage |
The output image. Its dimensions are either defined by the imageDimensions parameter, if the samplingMode parameter is MANUAL, or automatically computed to match the user-defined bounding box with a resolution close to that of the input image. Its calibration is automatically adapted. Its type and interpretation are the same as the input image. | Image | null |
Object Examples
auto polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" ); ResampleAffine2d resampleAffine2dAlgo; resampleAffine2dAlgo.setInputImage( polystyrene ); resampleAffine2dAlgo.setInterpolationType( ResampleAffine2d::InterpolationType::LINEAR ); resampleAffine2dAlgo.setBoundingBoxMin( {10, 15} ); resampleAffine2dAlgo.setBoundingBoxMax( {40, 50} ); resampleAffine2dAlgo.setBoundingBoxAngle( 0 ); resampleAffine2dAlgo.setSamplingMode( ResampleAffine2d::SamplingMode::AUTOMATIC ); resampleAffine2dAlgo.setImageDimensions( {100, 100} ); resampleAffine2dAlgo.setPaddingValue( 0 ); resampleAffine2dAlgo.setTransform( iolink::Matrix3d::identity() ); resampleAffine2dAlgo.execute(); std::cout << "outputImage:" << resampleAffine2dAlgo.outputImage()->toString();
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif")) resample_affine_2d_algo = imagedev.ResampleAffine2d() resample_affine_2d_algo.input_image = polystyrene resample_affine_2d_algo.interpolation_type = imagedev.ResampleAffine2d.LINEAR resample_affine_2d_algo.bounding_box_min = [10, 15] resample_affine_2d_algo.bounding_box_max = [40, 50] resample_affine_2d_algo.bounding_box_angle = 0 resample_affine_2d_algo.sampling_mode = imagedev.ResampleAffine2d.AUTOMATIC resample_affine_2d_algo.image_dimensions = [100, 100] resample_affine_2d_algo.padding_value = 0 resample_affine_2d_algo.transform = np.identity(3) resample_affine_2d_algo.execute() print("output_image:", str(resample_affine_2d_algo.output_image))
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" ); IOLink.Matrix3d transform = IOLink.Matrix3d.Identity(); ResampleAffine2d resampleAffine2dAlgo = new ResampleAffine2d { inputImage = polystyrene, interpolationType = ResampleAffine2d.InterpolationType.LINEAR, boundingBoxMin = new double[]{10, 15}, boundingBoxMax = new double[]{40, 50}, boundingBoxAngle = 0, samplingMode = ResampleAffine2d.SamplingMode.AUTOMATIC, imageDimensions = new uint[]{100, 100}, paddingValue = 0, transform = transform }; resampleAffine2dAlgo.Execute(); Console.WriteLine( "outputImage:" + resampleAffine2dAlgo.outputImage.ToString() );
Function Examples
auto polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" ); auto result = resampleAffine2d( polystyrene, ResampleAffine2d::InterpolationType::LINEAR, {10, 15}, {40, 50}, 0, ResampleAffine2d::SamplingMode::AUTOMATIC, {100, 100}, 0, iolink::Matrix3d::identity() ); std::cout << "outputImage:" << result->toString();
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif")) result = imagedev.resample_affine_2d(polystyrene, imagedev.ResampleAffine2d.LINEAR, [10, 15], [40, 50], 0, imagedev.ResampleAffine2d.AUTOMATIC, [100, 100], 0, np.identity(3)) print("output_image:", str(result))
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" ); IOLink.Matrix3d transform = IOLink.Matrix3d.Identity(); IOLink.ImageView result = Processing.ResampleAffine2d( polystyrene, ResampleAffine2d.InterpolationType.LINEAR, new double[]{10, 15}, new double[]{40, 50}, 0, ResampleAffine2d.SamplingMode.AUTOMATIC, new uint[]{100, 100}, 0, transform ); Console.WriteLine( "outputImage:" + result.ToString() );
© 2025 Thermo Fisher Scientific Inc. All rights reserved.