ImageDev

Resize2d

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 outputImage.
// Function prototype
std::shared_ptr< iolink::ImageView > resize2d( std::shared_ptr< iolink::ImageView > inputImage, iolink::Vector2i32 shape, Resize2d::InterpolationType interpolationType, std::shared_ptr< iolink::ImageView > outputImage = nullptr );
This function returns outputImage.
// Function prototype.
resize_2d(input_image: idt.ImageType,
          shape: Iterable[int] = [1024, 1024],
          interpolation_type: Resize2d.InterpolationType = Resize2d.InterpolationType.NEAREST_NEIGHBOR,
          output_image: idt.ImageType = None) -> idt.ImageType
This function returns outputImage.
// Function prototype.
public static IOLink.ImageView
Resize2d( IOLink.ImageView inputImage,
          int[] shape = null,
          Resize2d.InterpolationType interpolationType = ImageDev.Resize2d.InterpolationType.NEAREST_NEIGHBOR,
          IOLink.ImageView outputImage = null );

Class Syntax

Parameters

Parameter Name Description Type Supported Values Default Value
input
inputImage
The input image. Image Binary, Label, Grayscale or Multispectral nullptr
input
shape
The X and Y size of the new image, in pixels. Vector2i32 >0 {1024, 1024}
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.
Enumeration NEAREST_NEIGHBOR
output
outputImage
The output image. Its type is forced to the same value as the input. Its dimensions are defined by the shape parameter. Image nullptr
Parameter Name Description Type Supported Values Default Value
input
input_image
The input image. image Binary, Label, Grayscale or Multispectral None
input
shape
The X and Y size of the new image, in pixels. vector2i32 >0 [1024, 1024]
input
interpolation_type
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.
enumeration NEAREST_NEIGHBOR
output
output_image
The output image. Its type is forced to the same value as the input. Its dimensions are defined by the shape parameter. image None
Parameter Name Description Type Supported Values Default Value
input
inputImage
The input image. Image Binary, Label, Grayscale or Multispectral null
input
shape
The X and Y size of the new image, in pixels. Vector2i32 >0 {1024, 1024}
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.
Enumeration NEAREST_NEIGHBOR
output
outputImage
The output image. Its type is forced to the same value as the input. Its dimensions are defined by the shape parameter. Image null

Object Examples

auto polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" );

Resize2d resize2dAlgo;
resize2dAlgo.setInputImage( polystyrene );
resize2dAlgo.setShape( {1024, 1024} );
resize2dAlgo.setInterpolationType( Resize2d::InterpolationType::NEAREST_NEIGHBOR );
resize2dAlgo.execute();

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

resize_2d_algo = imagedev.Resize2d()
resize_2d_algo.input_image = polystyrene
resize_2d_algo.shape = [1024, 1024]
resize_2d_algo.interpolation_type = imagedev.Resize2d.NEAREST_NEIGHBOR
resize_2d_algo.execute()

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

Resize2d resize2dAlgo = new Resize2d
{
    inputImage = polystyrene,
    shape = new int[]{1024, 1024},
    interpolationType = Resize2d.InterpolationType.NEAREST_NEIGHBOR
};
resize2dAlgo.Execute();

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

Function Examples

auto polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" );

auto result = resize2d( polystyrene, {1024, 1024}, Resize2d::InterpolationType::NEAREST_NEIGHBOR );

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

result = imagedev.resize_2d(polystyrene, [1024, 1024], imagedev.Resize2d.NEAREST_NEIGHBOR)

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

IOLink.ImageView result = Processing.Resize2d( polystyrene, new int[]{1024, 1024}, Resize2d.InterpolationType.NEAREST_NEIGHBOR );

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