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 );
This function returns outputImage.
// Function prototype.
filter_by_measurement( input_object_image,
                       input_gray_image,
                       measurement = "",
                       measurement_filter_type = FilterByMeasurement.MeasurementFilterType.HIGHEST_VALUES,
                       object_count = 1,
                       output_image = None )
This function returns outputImage.
// Function prototype.
public static IOLink.ImageView
FilterByMeasurement( IOLink.ImageView inputObjectImage,
                     IOLink.ImageView inputGrayImage,
                     string measurement = "",
                     FilterByMeasurement.MeasurementFilterType measurementFilterType = ImageDev.FilterByMeasurement.MeasurementFilterType.HIGHEST_VALUES,
                     Int32 objectCount = 1,
                     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
Parameter Name Description Type Supported Values Default Value
input
input_object_image
The input binary or label image representing the objects to be filtered. image Binary or Label None
input
input_gray_image
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 None
input
measurement
The filtering measurement. measurement ""
input
measurement_filter_type
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
object_count
The number of objects to be retained. int32 >=1 1
output
output_image
The output image. Its dimensions and type are forced to the same values as the input. image None
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 null
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 null
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 null

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

filter_by_measurement_algo = imagedev.FilterByMeasurement()
filter_by_measurement_algo.input_object_image = polystyrene_sep_label
filter_by_measurement_algo.input_gray_image = polystyrene
filter_by_measurement_algo.measurement = "Area2d"
filter_by_measurement_algo.measurement_filter_type = imagedev.FilterByMeasurement.HIGHEST_VALUES
filter_by_measurement_algo.object_count = 1
filter_by_measurement_algo.execute()

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

FilterByMeasurement filterByMeasurementAlgo = new FilterByMeasurement
{
    inputObjectImage = polystyrene_sep_label,
    inputGrayImage = polystyrene,
    measurement = "Area2d",
    measurementFilterType = FilterByMeasurement.MeasurementFilterType.HIGHEST_VALUES,
    objectCount = 1
};
filterByMeasurementAlgo.Execute();

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

result = imagedev.filter_by_measurement( polystyrene_sep_label, polystyrene, "Area2d", imagedev.FilterByMeasurement.HIGHEST_VALUES, 1 )

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

IOLink.ImageView result = Processing.FilterByMeasurement( polystyrene_sep_label, polystyrene, "Area2d", FilterByMeasurement.MeasurementFilterType.HIGHEST_VALUES, 1 );

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