ImageDev

SampleImage2d

Performs a subsampling of a two-dimensional image.

Access to parameter description

The SampleImage2d algorithm subsamples an image by an integer factor for the X and Y coordinates. For example, specifying integer factors of 4 and 8 generates an output image retaining the value of one pixel out of four in the X axis direction and one out of eight in the Y axis direction.

See also

Function Syntax

This function returns outputImage.
// Function prototype
std::shared_ptr< iolink::ImageView > sampleImage2d( std::shared_ptr< iolink::ImageView > inputImage, int32_t sampleFactorX, int32_t sampleFactorY, std::shared_ptr< iolink::ImageView > outputImage = NULL );

Class Syntax

Parameters

Parameter Name Description Type Supported Values Default Value
input
sampleFactorX
The X axis sampling factor. Int32 >=1 2
input
sampleFactorY
The Y axis sampling factor. Int32 >=1 2
input
inputImage
The input image. Image Binary, Label, Grayscale or Multispectral nullptr
output
outputImage
The output image. Its dimensions are equal to the input image dimensions divided by the sampling factor in each direction. Image nullptr

Object Examples

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

SampleImage2d sampleImage2dAlgo;
sampleImage2dAlgo.setInputImage( polystyrene );
sampleImage2dAlgo.setSampleFactorX( 2 );
sampleImage2dAlgo.setSampleFactorY( 2 );
sampleImage2dAlgo.execute();

std::cout << "outputImage:" << sampleImage2dAlgo.outputImage()->toString();

Function Examples

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

auto result = sampleImage2d( polystyrene, 2, 2 );

std::cout << "outputImage:" << result->toString();