ImageDev

ResampleElastic2d

Resamples an image after applying a transformation described by a displacement field.

Access to parameter description

For an introduction: section Image Registration.

This algorithm generates a new image in accordance with the elastic transformation defined by a displacement field, for instance given by the ElasticRegistration2d algorithm.
This resampling can be performed by controlling several parameters such has the output resolution, calibration or the policy for filling undefined values.

<b> (a) </b>
(a)
<b> (b) </b>
(b)
<b> (c) </b>
(c)
Figure 1. Elastic resampling: (a) the image to resample (artificially distorted image),
(b) the displacement field magnitude, (c) the resampled image
See also

Function Syntax

This function returns the outputImage output parameter.
// Function prototype.
std::shared_ptr< iolink::ImageView >
resampleElastic2d( std::shared_ptr< iolink::ImageView > inputImage,
                   std::shared_ptr< iolink::ImageView > inputDisplacementField,
                   ResampleElastic2d::ExtrapolationType extrapolationType,
                   ResampleElastic2d::InterpolationType interpolationType,
                   iolink::Vector2d origin,
                   iolink::Vector2d voxelSize,
                   iolink::Vector2u32 imageDimensions,
                   double paddingValue,
                   std::shared_ptr< iolink::ImageView > outputImage = NULL );
This function returns the outputImage output parameter.
// Function prototype.
resample_elastic_2d( input_image,
                     input_displacement_field,
                     extrapolation_type = ResampleElastic2d.ExtrapolationType.PADDING_VALUE,
                     interpolation_type = ResampleElastic2d.InterpolationType.LINEAR,
                     origin = [0, 0],
                     voxel_size = [1, 1],
                     image_dimensions = [100, 100],
                     padding_value = 0,
                     output_image = None )
This function returns the outputImage output parameter.
// Function prototype.
public static IOLink.ImageView
ResampleElastic2d( IOLink.ImageView inputImage,
                   IOLink.ImageView inputDisplacementField,
                   ResampleElastic2d.ExtrapolationType extrapolationType = ImageDev.ResampleElastic2d.ExtrapolationType.PADDING_VALUE,
                   ResampleElastic2d.InterpolationType interpolationType = ImageDev.ResampleElastic2d.InterpolationType.LINEAR,
                   double[] origin = null,
                   double[] voxelSize = null,
                   uint[] imageDimensions = null,
                   double paddingValue = 0,
                   IOLink.ImageView outputImage = null );

Class Syntax

Parameters

Class Name ResampleElastic2d

Parameter Name Description Type Supported Values Default Value
input
inputImage
The grayscale input image to resample. It can have integer or floating point data type and several spectral channels. Image Grayscale nullptr
input
inputDisplacementField
The displacement field mapping the output pixels to the input pixels. It must have exactly two channels and 32-bit float data type. Each pixel of this image image contains two values: a displacement in the X direction (first channel) and one in the Y direction (second channel). Image Multispectral nullptr
input
extrapolationType
The type of extrapolation used to fill areas with no antecedent in the input image.
PADDING_VALUE A constant value is used for extrapolation.
NEAREST_VALUE The value of the nearest point is used for extrapolation.
Enumeration PADDING_VALUE
input
interpolationType
The type of interpolation used.
NEAREST_NEIGHBOR The value of the intensity is linearly interpolated in all directions.
LINEAR The value of the intensity is equal to the nearest intensity.
Enumeration LINEAR
input
origin
The origin of the output image, in world coordinates. Vector2d Any value {0.f, 0.f}
input
voxelSize
The pixel size in world coordinates for the X and Y directions of the output image. Vector2d >0 {1.f, 1.f}
input
imageDimensions
The size in pixels of the output image in the X and Y directions. Vector2u32 != 0 {100, 100}
input
paddingValue
The padding value used to fill areas with no antecedent in the input image. This parameter is ignored if extrapolation type is not set to PADDING_VALUE. Float64 Any value 0
output
outputImage
The resampled output image. Its resolution and bounding box are defined by the origin, voxelSize, and imageDimensions parameters. Its type is forced to floating point precision (32-bit). Image nullptr

Object Examples

auto retina = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "retina.vip" );
auto retina_eigenvalues = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "retina_eigenvalues.vip" );

ResampleElastic2d resampleElastic2dAlgo;
resampleElastic2dAlgo.setInputImage( retina );
resampleElastic2dAlgo.setInputDisplacementField( retina_eigenvalues );
resampleElastic2dAlgo.setExtrapolationType( ResampleElastic2d::ExtrapolationType::PADDING_VALUE );
resampleElastic2dAlgo.setInterpolationType( ResampleElastic2d::InterpolationType::LINEAR );
resampleElastic2dAlgo.setOrigin( {0.0, 0.0} );
resampleElastic2dAlgo.setVoxelSize( {1.0, 1.0} );
resampleElastic2dAlgo.setImageDimensions( {100, 100} );
resampleElastic2dAlgo.setPaddingValue( 0 );
resampleElastic2dAlgo.execute();

std::cout << "outputImage:" << resampleElastic2dAlgo.outputImage()->toString();
retina = imagedev.read_vip_image(imagedev_data.get_image_path("retina.vip"))
retina_eigenvalues = imagedev.read_vip_image(imagedev_data.get_image_path("retina_eigenvalues.vip"))

resample_elastic_2d_algo = imagedev.ResampleElastic2d()
resample_elastic_2d_algo.input_image = retina
resample_elastic_2d_algo.input_displacement_field = retina_eigenvalues
resample_elastic_2d_algo.extrapolation_type = imagedev.ResampleElastic2d.PADDING_VALUE
resample_elastic_2d_algo.interpolation_type = imagedev.ResampleElastic2d.LINEAR
resample_elastic_2d_algo.origin = [0.0, 0.0]
resample_elastic_2d_algo.voxel_size = [1.0, 1.0]
resample_elastic_2d_algo.image_dimensions = [100, 100]
resample_elastic_2d_algo.padding_value = 0
resample_elastic_2d_algo.execute()

print( "output_image:", str( resample_elastic_2d_algo.output_image ) )
ImageView retina = Data.ReadVipImage( @"Data/images/retina.vip" );
ImageView retina_eigenvalues = Data.ReadVipImage( @"Data/images/retina_eigenvalues.vip" );

ResampleElastic2d resampleElastic2dAlgo = new ResampleElastic2d
{
    inputImage = retina,
    inputDisplacementField = retina_eigenvalues,
    extrapolationType = ResampleElastic2d.ExtrapolationType.PADDING_VALUE,
    interpolationType = ResampleElastic2d.InterpolationType.LINEAR,
    origin = new double[]{0.0, 0.0},
    voxelSize = new double[]{1.0, 1.0},
    imageDimensions = new uint[]{100, 100},
    paddingValue = 0
};
resampleElastic2dAlgo.Execute();

Console.WriteLine( "outputImage:" + resampleElastic2dAlgo.outputImage.ToString() );

Function Examples

auto retina = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "retina.vip" );
auto retina_eigenvalues = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "retina_eigenvalues.vip" );

auto result = resampleElastic2d( retina, retina_eigenvalues, ResampleElastic2d::ExtrapolationType::PADDING_VALUE, ResampleElastic2d::InterpolationType::LINEAR, {0.0, 0.0}, {1.0, 1.0}, {100, 100}, 0 );

std::cout << "outputImage:" << result->toString();
retina = imagedev.read_vip_image(imagedev_data.get_image_path("retina.vip"))
retina_eigenvalues = imagedev.read_vip_image(imagedev_data.get_image_path("retina_eigenvalues.vip"))

result = imagedev.resample_elastic_2d( retina, retina_eigenvalues, imagedev.ResampleElastic2d.PADDING_VALUE, imagedev.ResampleElastic2d.LINEAR, [0.0, 0.0], [1.0, 1.0], [100, 100], 0 )

print( "output_image:", str( result ) )
ImageView retina = Data.ReadVipImage( @"Data/images/retina.vip" );
ImageView retina_eigenvalues = Data.ReadVipImage( @"Data/images/retina_eigenvalues.vip" );

IOLink.ImageView result = Processing.ResampleElastic2d( retina, retina_eigenvalues, ResampleElastic2d.ExtrapolationType.PADDING_VALUE, ResampleElastic2d.InterpolationType.LINEAR, new double[]{0.0, 0.0}, new double[]{1.0, 1.0}, new uint[]{100, 100}, 0 );

Console.WriteLine( "outputImage:" + result.ToString() );