ImageDev

CropImage2d

Extracts a two-dimensional rectangular region from an image.

Access to parameter description

CropImage2d copies a rectangular area, defined by an origin and a size in pixels, from an input image $I$ and creates an output image $O$ from this selected region.

See also

Function Syntax

This function returns the outputImage output parameter.
// Function prototype.
std::shared_ptr< iolink::ImageView >
cropImage2d( std::shared_ptr< iolink::ImageView > inputImage,
             iolink::Vector2i32 areaOrigin,
             iolink::Vector2i32 areaSize,
             std::shared_ptr< iolink::ImageView > outputImage = NULL );
This function returns the outputImage output parameter.
// Function prototype.
crop_image_2d( input_image,
               area_origin = [1, 1],
               area_size = [100, 100],
               output_image = None )
This function returns the outputImage output parameter.
// Function prototype.
public static IOLink.ImageView
CropImage2d( IOLink.ImageView inputImage,
             int[] areaOrigin = null,
             int[] areaSize = null,
             IOLink.ImageView outputImage = null );

Class Syntax

Parameters

Class Name CropImage2d

Parameter Name Description Type Supported Values Default Value
input
inputImage
The input image. Image Binary, Label, Grayscale or Multispectral nullptr
input
areaOrigin
The origin of the area (the X and Y pixel coordinates of the input image corresponding to the output image origin). Vector2i32 >=0 {1, 1}
input
areaSize
The size, in pixels, of the area (the X and Y dimensions of the output image). Vector2i32 >0 {100, 100}
output
outputImage
The output image. Image nullptr

Object Examples

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

CropImage2d cropImage2dAlgo;
cropImage2dAlgo.setInputImage( polystyrene );
cropImage2dAlgo.setAreaOrigin( {1, 1} );
cropImage2dAlgo.setAreaSize( {100, 100} );
cropImage2dAlgo.execute();

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

crop_image_2d_algo = imagedev.CropImage2d()
crop_image_2d_algo.input_image = polystyrene
crop_image_2d_algo.area_origin = [1, 1]
crop_image_2d_algo.area_size = [100, 100]
crop_image_2d_algo.execute()

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

CropImage2d cropImage2dAlgo = new CropImage2d
{
    inputImage = polystyrene,
    areaOrigin = new int[]{1, 1},
    areaSize = new int[]{100, 100}
};
cropImage2dAlgo.Execute();

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

Function Examples

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

auto result = cropImage2d( polystyrene, {1, 1}, {100, 100} );

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

result = imagedev.crop_image_2d( polystyrene, [1, 1], [100, 100] )

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

IOLink.ImageView result = Processing.CropImage2d( polystyrene, new int[]{1, 1}, new int[]{100, 100} );

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