ResampleAffine3d
Resamples an 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 transformation (boundingBoxTransform).
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 transformation (boundingBoxTransform).
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 sub-volume with an arbitrary voxel 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 the outputImage output parameter.
// Function prototype. std::shared_ptr< iolink::ImageView > resampleAffine3d( std::shared_ptr< iolink::ImageView > inputImage, iolink::Vector3d boundingBoxMin, iolink::Vector3d boundingBoxMax, iolink::Matrix4d boundingBoxTransform, ResampleAffine3d::SamplingMode samplingMode, iolink::Vector3u32 imageDimensions, ResampleAffine3d::InterpolationType interpolationType, double paddingValue, iolink::Matrix4d transform, std::shared_ptr< iolink::ImageView > outputImage = NULL );
This function returns the outputImage output parameter.
// Function prototype. resample_affine_3d( input_image, bounding_box_min = [0, 0, 0], bounding_box_max = [1, 1, 1], bounding_box_transform = _np.identity(4), sampling_mode = ResampleAffine3d.SamplingMode.AUTOMATIC, image_dimensions = [1, 1, 1], interpolation_type = ResampleAffine3d.InterpolationType.LINEAR, padding_value = 0, transform = _np.identity(4), output_image = None )
This function returns the outputImage output parameter.
// Function prototype. public static IOLink.ImageView ResampleAffine3d( IOLink.ImageView inputImage, double[] boundingBoxMin = null, double[] boundingBoxMax = null, IOLink.Matrix4d boundingBoxTransform = null, ResampleAffine3d.SamplingMode samplingMode = ImageDev.ResampleAffine3d.SamplingMode.AUTOMATIC, uint[] imageDimensions = null, ResampleAffine3d.InterpolationType interpolationType = ImageDev.ResampleAffine3d.InterpolationType.LINEAR, double paddingValue = 0, IOLink.Matrix4d transform = null, IOLink.ImageView outputImage = null );
Class Syntax
Parameters
Class Name | ResampleAffine3d |
---|
Parameter Name | Description | Type | Supported Values | Default Value | |||||
---|---|---|---|---|---|---|---|---|---|
inputImage |
The input image to resample. It can have integer or floating point data type. | Image | Grayscale | nullptr | |||||
boundingBoxMin |
The input bounding box origin, in world coordinates. The resulting bounding box is an axis aligned box in 3D space. | Vector3d | Any value | {0.f, 0.f, 0.f} | |||||
boundingBoxMax |
The input bounding box end point, in world coordinates. The resulting bounding box is an axis aligned box in 3D space. | Vector3d | Any value | {1.f, 1.f, 1.f} | |||||
boundingBoxTransform |
The geometric transformation defining the bounding box orientation of the output image, represented by a 4x4 matrix. | Matrix4d | IDENTITY | ||||||
samplingMode |
The way to determine how the output voxel size is computed.
|
Enumeration | AUTOMATIC | ||||||
imageDimensions |
The size in pixels of the output image in each axis direction. If the parameter samplingMode is not set to MANUAL, this parameter is ignored. | Vector3u32 | != 0 | {1, 1, 1} | |||||
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 voxel position is outside the bounding box of the input image. | Float64 | Any value | 0 | |||||
transform |
The geometric transformation applied to all output voxel positions before the interpolation, represented by a 4x4 matrix. | Matrix4d | IDENTITY | ||||||
outputImage |
Specifies the output image. Its dimensions are defined by the imageDimensions parameter. Its type, calibration, and interpretation are the same as the input image. | Image | nullptr |
Object Examples
auto foam = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "foam.vip" ); ResampleAffine3d resampleAffine3dAlgo; resampleAffine3dAlgo.setInputImage( foam ); resampleAffine3dAlgo.setBoundingBoxMin( {0, 0, 0} ); resampleAffine3dAlgo.setBoundingBoxMax( {10, 10, 10} ); resampleAffine3dAlgo.setBoundingBoxTransform( iolink::Matrix4d::identity() ); resampleAffine3dAlgo.setSamplingMode( ResampleAffine3d::SamplingMode::AUTOMATIC ); resampleAffine3dAlgo.setImageDimensions( {10, 10, 10} ); resampleAffine3dAlgo.setInterpolationType( ResampleAffine3d::InterpolationType::LINEAR ); resampleAffine3dAlgo.setPaddingValue( 0 ); resampleAffine3dAlgo.setTransform( iolink::Matrix4d({1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0}) ); resampleAffine3dAlgo.execute(); std::cout << "outputImage:" << resampleAffine3dAlgo.outputImage()->toString();
foam = imagedev.read_vip_image(imagedev_data.get_image_path("foam.vip")) resample_affine_3d_algo = imagedev.ResampleAffine3d() resample_affine_3d_algo.input_image = foam resample_affine_3d_algo.bounding_box_min = [0, 0, 0] resample_affine_3d_algo.bounding_box_max = [10, 10, 10] resample_affine_3d_algo.bounding_box_transform = np.identity(4) resample_affine_3d_algo.sampling_mode = imagedev.ResampleAffine3d.AUTOMATIC resample_affine_3d_algo.image_dimensions = [10, 10, 10] resample_affine_3d_algo.interpolation_type = imagedev.ResampleAffine3d.LINEAR resample_affine_3d_algo.padding_value = 0 resample_affine_3d_algo.transform = np.array([1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0]).reshape((4,4)) resample_affine_3d_algo.execute() print( "output_image:", str( resample_affine_3d_algo.output_image ) );
ImageView foam = Data.ReadVipImage( @"Data/images/foam.vip" ); IOLink.Matrix4d boundingBoxTransform = IOLink.Matrix4d.Identity() ; var transformValues = new double[]{1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0}; IOLink.Matrix4d transform = new IOLink.Matrix4d() ; for ( uint i = 0; i < 4; i++ ) { for ( uint j = 0; j < 4; j++ ) { transform.SetAt(i,j,transformValues[i*4+j]); } } ResampleAffine3d resampleAffine3dAlgo = new ResampleAffine3d { inputImage = foam, boundingBoxMin = new double[]{0, 0, 0}, boundingBoxMax = new double[]{10, 10, 10}, boundingBoxTransform = boundingBoxTransform, samplingMode = ResampleAffine3d.SamplingMode.AUTOMATIC, imageDimensions = new uint[]{10, 10, 10}, interpolationType = ResampleAffine3d.InterpolationType.LINEAR, paddingValue = 0, transform = transform }; resampleAffine3dAlgo.Execute(); Console.WriteLine( "outputImage:" + resampleAffine3dAlgo.outputImage.ToString() );
Function Examples
auto foam = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "foam.vip" ); auto result = resampleAffine3d( foam, {0, 0, 0}, {10, 10, 10}, iolink::Matrix4d::identity(), ResampleAffine3d::SamplingMode::AUTOMATIC, {10, 10, 10}, ResampleAffine3d::InterpolationType::LINEAR, 0, iolink::Matrix4d({1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0}) ); std::cout << "outputImage:" << result->toString();
foam = imagedev.read_vip_image(imagedev_data.get_image_path("foam.vip")) result = imagedev.resample_affine_3d( foam, [0, 0, 0], [10, 10, 10], np.identity(4), imagedev.ResampleAffine3d.AUTOMATIC, [10, 10, 10], imagedev.ResampleAffine3d.LINEAR, 0, np.array([1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0]).reshape((4,4)) ) print( "output_image:", str( result ) );
ImageView foam = Data.ReadVipImage( @"Data/images/foam.vip" ); IOLink.Matrix4d boundingBoxTransform = IOLink.Matrix4d.Identity() ; var transformValues = new double[]{1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0}; IOLink.Matrix4d transform = new IOLink.Matrix4d() ; for ( uint i = 0; i < 4; i++ ) { for ( uint j = 0; j < 4; j++ ) { transform.SetAt(i,j,transformValues[i*4+j]); } } IOLink.ImageView result = Processing.ResampleAffine3d( foam, new double[]{0, 0, 0}, new double[]{10, 10, 10}, boundingBoxTransform, ResampleAffine3d.SamplingMode.AUTOMATIC, new uint[]{10, 10, 10}, ResampleAffine3d.InterpolationType.LINEAR, 0, transform ); Console.WriteLine( "outputImage:" + result.ToString() );