ImageDev

RescaleImage2d

Generates a two-dimensional image with a new size using a user-defined interpolation mode.

Access to parameter description

This algorithm resamples a 2D image to generate a new image with a different size by applying a user-defined interpolation mode.

See also

Function Syntax

This function returns the outputImage output parameter.
// Function prototype.
std::shared_ptr< iolink::ImageView >
rescaleImage2d( std::shared_ptr< iolink::ImageView > inputImage,
                int32_t imageSizeX,
                int32_t imageSizeY,
                RescaleImage2d::InterpolationType interpolationType,
                std::shared_ptr< iolink::ImageView > outputImage = NULL );
This function returns the outputImage output parameter.
// Function prototype.
rescale_image_2d( input_image,
                  image_size_x = 1024,
                  image_size_y = 1024,
                  interpolation_type = RescaleImage2d.InterpolationType.NEAREST_NEIGHBOR,
                  output_image = None )
This function returns the outputImage output parameter.
// Function prototype.
public static IOLink.ImageView
RescaleImage2d( IOLink.ImageView inputImage,
                Int32 imageSizeX = 1024,
                Int32 imageSizeY = 1024,
                RescaleImage2d.InterpolationType interpolationType = ImageDev.RescaleImage2d.InterpolationType.NEAREST_NEIGHBOR,
                IOLink.ImageView outputImage = null );

Class Syntax

Parameters

Class Name RescaleImage2d

Parameter Name Description Type Supported Values Default Value
input
imageSizeX
The X size of the new image, in pixels. Int32 >=1 1024
input
imageSizeY
The Y size of the new image, in pixels. Int32 >=1 1024
input
inputImage
The input image. Image Binary, Label, Grayscale or Multispectral nullptr
input
interpolationType
The interpolation mode. Method used to calculate the intensity of each pixel in the result image.
NEAREST_NEIGHBOR Assign the gray level of the nearest pixel.
LINEAR Assign the bilinear interpolation from the four nearest pixels.
SPLINE Assign the cubic interpolation from the nearest pixels.
Enumeration NEAREST_NEIGHBOR
output
outputImage
The output image. Its type is forced to the same value as the input. Its dimensions depend on the image size parameters. Image nullptr

Object Examples

std::shared_ptr< iolink::ImageView > polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" );

RescaleImage2d rescaleImage2dAlgo;
rescaleImage2dAlgo.setInputImage( polystyrene );
rescaleImage2dAlgo.setImageSizeX( 256 );
rescaleImage2dAlgo.setImageSizeY( 256 );
rescaleImage2dAlgo.setInterpolationType( RescaleImage2d::InterpolationType::NEAREST_NEIGHBOR );
rescaleImage2dAlgo.execute();

std::cout << "outputImage:" << rescaleImage2dAlgo.outputImage()->toString();
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif"))

rescale_image_2d_algo = imagedev.RescaleImage2d()
rescale_image_2d_algo.input_image = polystyrene
rescale_image_2d_algo.image_size_x = 256
rescale_image_2d_algo.image_size_y = 256
rescale_image_2d_algo.interpolation_type = imagedev.RescaleImage2d.NEAREST_NEIGHBOR
rescale_image_2d_algo.execute()

print( "output_image:", str( rescale_image_2d_algo.output_image ) );
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" );

RescaleImage2d rescaleImage2dAlgo = new RescaleImage2d
{
    inputImage = polystyrene,
    imageSizeX = 256,
    imageSizeY = 256,
    interpolationType = RescaleImage2d.InterpolationType.NEAREST_NEIGHBOR
};
rescaleImage2dAlgo.Execute();

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

Function Examples

std::shared_ptr< iolink::ImageView > polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" );

auto result = rescaleImage2d( polystyrene, 256, 256, RescaleImage2d::InterpolationType::NEAREST_NEIGHBOR );

std::cout << "outputImage:" << result->toString();
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif"))

result = imagedev.rescale_image_2d( polystyrene, 256, 256, imagedev.RescaleImage2d.NEAREST_NEIGHBOR )

print( "output_image:", str( result ) );
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" );

IOLink.ImageView result = Processing.RescaleImage2d( polystyrene, 256, 256, RescaleImage2d.InterpolationType.NEAREST_NEIGHBOR );

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