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 an arbitrary 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 an arbitrary 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 an arbitrary region of interest with an arbitrary 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, iolink::Vector2d boundingBoxMin, iolink::Vector2d boundingBoxMax, double boundingBoxAngle, ResampleAffine2d::SamplingMode samplingMode, iolink::Vector2u32 imageDimensions, double paddingValue, iolink::Matrix3d transform, std::shared_ptr< iolink::ImageView > outputImage = NULL );
This function returns outputImage.
// Function prototype. resample_affine_2d( input_image, interpolation_type = ResampleAffine2d.InterpolationType.LINEAR, bounding_box_min = [0, 0], bounding_box_max = [1, 1], bounding_box_angle = 0, sampling_mode = ResampleAffine2d.SamplingMode.AUTOMATIC, image_dimensions = [100, 100], padding_value = 0, transform = _np.identity(3), output_image = None )
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 |
Minimum coordinates in X and Y of the box that defines the image domain after rotation. Note that the output image domain is the previously defined box rotated to an angle equal to the value of the parameter "boundingBoxAngle". | Vector2d | Any value | {0.f, 0.f} | |||||
boundingBoxMax |
Maximum coordinates in X and Y of the box that defines the image domain after rotation. Note that the output image domain is the previously defined box rotated to an angle equal to the value of the parameter "boundingBoxAngle". | 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 all output pixel positions before the interpolation, represented by a 3x3 matrix. | 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 |
Minimum coordinates in X and Y of the box that defines the image domain after rotation. Note that the output image domain is the previously defined box rotated to an angle equal to the value of the parameter "boundingBoxAngle". | vector2d | Any value | [0, 0] | |||||
bounding_box_max |
Maximum coordinates in X and Y of the box that defines the image domain after rotation. Note that the output image domain is the previously defined box rotated to an angle equal to the value of the parameter "boundingBoxAngle". | 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 all output pixel positions before the interpolation, represented by a 3x3 matrix. | 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 |
Minimum coordinates in X and Y of the box that defines the image domain after rotation. Note that the output image domain is the previously defined box rotated to an angle equal to the value of the parameter "boundingBoxAngle". | Vector2d | Any value | {0f, 0f} | |||||
boundingBoxMax |
Maximum coordinates in X and Y of the box that defines the image domain after rotation. Note that the output image domain is the previously defined box rotated to an angle equal to the value of the parameter "boundingBoxAngle". | 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 all output pixel positions before the interpolation, represented by a 3x3 matrix. | 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
std::shared_ptr< iolink::ImageView > 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
std::shared_ptr< iolink::ImageView > 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() );