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 the outputImage output parameter.
// 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 );
This function returns the outputImage output parameter.
// Function prototype.
sample_image_2d( input_image,
                 sample_factor_x = 2,
                 sample_factor_y = 2,
                 output_image = None )
This function returns the outputImage output parameter.
// Function prototype.
public static IOLink.ImageView
SampleImage2d( IOLink.ImageView inputImage,
               Int32 sampleFactorX = 2,
               Int32 sampleFactorY = 2,
               IOLink.ImageView outputImage = null );

Class Syntax

Parameters

Class Name SampleImage2d

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();
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif"))

sample_image_2d_algo = imagedev.SampleImage2d()
sample_image_2d_algo.input_image = polystyrene
sample_image_2d_algo.sample_factor_x = 2
sample_image_2d_algo.sample_factor_y = 2
sample_image_2d_algo.execute()

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

SampleImage2d sampleImage2dAlgo = new SampleImage2d
{
    inputImage = polystyrene,
    sampleFactorX = 2,
    sampleFactorY = 2
};
sampleImage2dAlgo.Execute();

Console.WriteLine( "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();
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif"))

result = imagedev.sample_image_2d( polystyrene, 2, 2 )

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

IOLink.ImageView result = Processing.SampleImage2d( polystyrene, 2, 2 );

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