ImageDev

FilterByMeasurement

Preserves a predefined number of objects according to a selected measurement.

Access to parameter description

For an introduction, see:
This algorithm filters objects contained into a label or binary image in accordance with a predefined measurement and a filtering criterion.

If the input image is a binary image, the resulting image is binary. If the input image is a label image, the resulting image is a label image with values sorted with respect to the targets measurement and criterion.

Function Syntax

This function returns outputImage.
// Function prototype
std::shared_ptr< iolink::ImageView > filterByMeasurement( std::shared_ptr< iolink::ImageView > inputObjectImage, std::shared_ptr< iolink::ImageView > inputGrayImage, std::string measurement, FilterByMeasurement::MeasurementFilterType measurementFilterType, int32_t objectCount, std::shared_ptr< iolink::ImageView > outputImage = NULL );

Class Syntax

Parameters

Parameter Name Description Type Supported Values Default Value
input
inputObjectImage
The input binary or label image representing the objects to be filtered. Image Binary or Label nullptr
input
inputGrayImage
The input grayscale image that contains the intensity information. It must have the same dimensions as the object input image. It is only used with measurements requiring an intensity image, and is ignored with other measurements. If it equals null, the object input image will be used as the intensity input image. Image Binary, Label or Grayscale nullptr
input
measurement
The filtering measurement. Measurement ""
input
measurementFilterType
The filtering criterion.
HIGHEST_VALUES The algorithm preserves objects with highest values of the measurement.
LOWEST_VALUES The algorithm preserves objects with lowest values of the measurement.
Enumeration HIGHEST_VALUES
input
objectCount
The number of objects to be retained. Int32 >=1 1
output
outputImage
The output image. Its dimensions and type are forced to the same values as the input. Image nullptr

Object Examples

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

FilterByMeasurement filterByMeasurementAlgo;
filterByMeasurementAlgo.setInputObjectImage( polystyrene_sep_label );
filterByMeasurementAlgo.setInputGrayImage( polystyrene );
filterByMeasurementAlgo.setMeasurement( "Area2d" );
filterByMeasurementAlgo.setMeasurementFilterType( FilterByMeasurement::MeasurementFilterType::HIGHEST_VALUES );
filterByMeasurementAlgo.setObjectCount( 1 );
filterByMeasurementAlgo.execute();

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

Function Examples

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

auto result = filterByMeasurement( polystyrene_sep_label, polystyrene, "Area2d", FilterByMeasurement::MeasurementFilterType::HIGHEST_VALUES, 1 );

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