ImageDev

LabelFilteringAnalysis

Computes measurements on objects and filters them from a label image.

Access to parameter description

For an introduction: This algorithm is similar to the LabelAnalysis algorithm except that it applies a filter formula with its criteria to the analyzed image. Then it outputs the filtered label image and the corresponding analysis result object.

The input filter contains the criteria to preserve objects from the input label image. These criteria are defined by one or several analysis measurements ranges.

If the label input image has a coordinate system unit defined in its calibration property, the filter limit values and analysis results are expressed in this coordinate system unit.

See also

Function Syntax

This function returns a LabelFilteringAnalysisOutput structure containing outputAnalysis and outputLabelImage.
// Output structure of the labelFilteringAnalysis function.
struct LabelFilteringAnalysisOutput
{
    /// The output label image. Its dimensions and type are forced to the same values as the input.
    std::shared_ptr< iolink::ImageView > outputLabelImage;
    /// The output analysis.
    AnalysisMsr::Ptr outputAnalysis;
};

// Function prototype
LabelFilteringAnalysisOutput labelFilteringAnalysis( std::shared_ptr< iolink::ImageView > inputLabelImage, std::shared_ptr< iolink::ImageView > inputIntensityImage, std::string inputFilter, AnalysisMsr::Ptr outputAnalysis = nullptr, std::shared_ptr< iolink::ImageView > outputLabelImage = nullptr );
This function returns a tuple containing output_analysis and output_label_image.
// Function prototype.
label_filtering_analysis(input_label_image: idt.ImageType,
                         input_intensity_image: idt.ImageType,
                         input_filter: str = "",
                         output_analysis: Union[Any, None] = None,
                         output_label_image: idt.ImageType = None) -> Tuple[AnalysisMsr, idt.ImageType]
This function returns a LabelFilteringAnalysisOutput structure containing outputAnalysis and outputLabelImage.
/// Output structure of the LabelFilteringAnalysis function.
public struct LabelFilteringAnalysisOutput
{
    /// 
    /// The output label image. Its dimensions and type are forced to the same values as the input.
    /// 
    public IOLink.ImageView outputLabelImage;
    /// The output analysis.
    public AnalysisMsr outputAnalysis;
};

// Function prototype.
public static LabelFilteringAnalysisOutput
LabelFilteringAnalysis( IOLink.ImageView inputLabelImage,
                        IOLink.ImageView inputIntensityImage,
                        string inputFilter = "",
                        AnalysisMsr outputAnalysis = null,
                        IOLink.ImageView outputLabelImage = null );

Class Syntax

Parameters

Parameter Name Description Type Supported Values Default Value
input
inputLabelImage
The label input image Image Label nullptr
input
inputIntensityImage
The intensity input image. If it equals null, the label input image will be used as the intensity input image. Image Binary, Label, Grayscale or Multispectral nullptr
input
inputFilter
The input filter formula.
The Label Filtering section details how to create a filter.
Filter ""
output
outputLabelImage
The output label image. Its dimensions and type are forced to the same values as the input. Image nullptr
input and output
outputAnalysis
The output analysis. AnalysisMsr nullptr
Parameter Name Description Type Supported Values Default Value
input
input_label_image
The label input image image Label None
input
input_intensity_image
The intensity input image. If it equals null, the label input image will be used as the intensity input image. image Binary, Label, Grayscale or Multispectral None
input
input_filter
The input filter formula.
The Label Filtering section details how to create a filter.
filter ""
output
output_label_image
The output label image. Its dimensions and type are forced to the same values as the input. image None
input and output
output_analysis
The output analysis. AnalysisMsr None
Parameter Name Description Type Supported Values Default Value
input
inputLabelImage
The label input image Image Label null
input
inputIntensityImage
The intensity input image. If it equals null, the label input image will be used as the intensity input image. Image Binary, Label, Grayscale or Multispectral null
input
inputFilter
The input filter formula.
The Label Filtering section details how to create a filter.
Filter ""
output
outputLabelImage
The output label image. Its dimensions and type are forced to the same values as the input. Image null
input and output
outputAnalysis
The output analysis. AnalysisMsr null

Object Examples

auto polystyrene_sep_label = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene_sep_label.vip" );
auto polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" );
AnalysisMsr::Ptr analysis= AnalysisMsr::read( std::string( IMAGEDEVDATA_OBJECTS_FOLDER ) + "analysis.vip" );

LabelFilteringAnalysis labelFilteringAnalysisAlgo;
labelFilteringAnalysisAlgo.setInputLabelImage( polystyrene_sep_label );
labelFilteringAnalysisAlgo.setInputIntensityImage( polystyrene );
labelFilteringAnalysisAlgo.setInputFilter( "Area>=3000" );
labelFilteringAnalysisAlgo.setOutputAnalysis( analysis );
labelFilteringAnalysisAlgo.execute();

std::cout << "Area2d: " << labelFilteringAnalysisAlgo.outputAnalysis()->get( NativeMeasurements::area2d )->value( 0 ) ;
std::cout << "outputLabelImage:" << labelFilteringAnalysisAlgo.outputLabelImage()->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"))
analysis = imagedev.AnalysisMsr.read(imagedev_data.get_object_path("analysis.vip"))

label_filtering_analysis_algo = imagedev.LabelFilteringAnalysis()
label_filtering_analysis_algo.input_label_image = polystyrene_sep_label
label_filtering_analysis_algo.input_intensity_image = polystyrene
label_filtering_analysis_algo.input_filter = "Area>=3000"
label_filtering_analysis_algo.output_analysis = analysis
label_filtering_analysis_algo.execute()

print("Area2d: ", str(label_filtering_analysis_algo.output_analysis.get(imagedev.native_measurements.Area2d).value(0)))
print("output_label_image:", str(label_filtering_analysis_algo.output_label_image))
ImageView polystyrene_sep_label = Data.ReadVipImage( @"Data/images/polystyrene_sep_label.vip" );
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" );
AnalysisMsr analysis = AnalysisMsr.Read( @"Data/objects/analysis.vip" );

LabelFilteringAnalysis labelFilteringAnalysisAlgo = new LabelFilteringAnalysis
{
    inputLabelImage = polystyrene_sep_label,
    inputIntensityImage = polystyrene,
    inputFilter = "Area>=3000",
    outputAnalysis = analysis
};
labelFilteringAnalysisAlgo.Execute();

Console.WriteLine( "Area2d: " + labelFilteringAnalysisAlgo.outputAnalysis.Get( NativeMeasurements.Area2d ).Value( 0 ) );
Console.WriteLine( "outputLabelImage:" + labelFilteringAnalysisAlgo.outputLabelImage.ToString() );

Function Examples

auto polystyrene_sep_label = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene_sep_label.vip" );
auto polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" );
AnalysisMsr::Ptr analysis= AnalysisMsr::read( std::string( IMAGEDEVDATA_OBJECTS_FOLDER ) + "analysis.vip" );

auto result = labelFilteringAnalysis( polystyrene_sep_label, polystyrene, "Area>=3000", analysis );

std::cout << "Area2d: " << result.outputAnalysis->get( NativeMeasurements::area2d )->value( 0 ) ;
std::cout << "outputLabelImage:" << result.outputLabelImage->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"))
analysis = imagedev.AnalysisMsr.read(imagedev_data.get_object_path("analysis.vip"))

result_output_analysis, result_output_label_image = imagedev.label_filtering_analysis(polystyrene_sep_label, polystyrene, "Area>=3000", analysis)

print("Area2d: ", str(result_output_analysis.get(imagedev.native_measurements.Area2d).value(0)))
print("output_label_image:", str(result_output_label_image))
ImageView polystyrene_sep_label = Data.ReadVipImage( @"Data/images/polystyrene_sep_label.vip" );
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" );
AnalysisMsr analysis = AnalysisMsr.Read( @"Data/objects/analysis.vip" );

Processing.LabelFilteringAnalysisOutput result = Processing.LabelFilteringAnalysis( polystyrene_sep_label, polystyrene, "Area>=3000", analysis );

Console.WriteLine(  "Area2d: " + result.outputAnalysis.Get( NativeMeasurements.Area2d ).Value( 0 )  );
Console.WriteLine( "outputLabelImage:" + result.outputLabelImage.ToString() );