ImageDev

LabelAnalysis

Computes a set of measurements on objects defined in a label image.

Access to parameter description

For an introduction: This algorithm computes a list of measurements for each label of the input image, and generates an output AnalysisMsr object containing the result values.

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

More details about each available measurement can be found in the NativeMeasurement object.

See also
@SEE_EXAMPLE UserGuide_ImageAnalysis_LabelAnalysis UserGuide_TypicalUseCases_ParticleAnalysis UserGuide_TypicalUseCases_PoreAnalysis UserGuide_ImageAnalysis_MeasurementBrowsing@END_SEE_EXAMPLE

Function Syntax

This function returns outputAnalysis.
// Function prototype
AnalysisMsr::Ptr labelAnalysis( std::shared_ptr< iolink::ImageView > inputLabelImage, std::shared_ptr< iolink::ImageView > inputIntensityImage, AnalysisMsr::Ptr outputAnalysis = NULL );
This function returns outputAnalysis.
// Function prototype.
label_analysis( input_label_image,
                input_intensity_image,
                output_analysis = None )
This function returns outputAnalysis.
// Function prototype.
public static AnalysisMsr
LabelAnalysis( IOLink.ImageView inputLabelImage,
               IOLink.ImageView inputIntensityImage,
               AnalysisMsr outputAnalysis = 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 and output
outputAnalysis
The input and output analysis. This object defines the features to measure and stores the results. 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 and output
output_analysis
The input and output analysis. This object defines the features to measure and stores the results. 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 and output
outputAnalysis
The input and output analysis. This object defines the features to measure and stores the results. AnalysisMsr 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" );

// Creates an analysis with Area2d and InverseCircularity2d measurements
AnalysisMsr::Ptr analysis( new AnalysisMsr() );
measurements::Area2d::Ptr areaMsr = analysis->select( NativeMeasurements::area2d );
measurements::InverseCircularity2d::Ptr inverseMsr = analysis->select( NativeMeasurements::inverseCircularity2d );

LabelAnalysis labelAnalysisAlgo;
labelAnalysisAlgo.setInputLabelImage( polystyrene_sep_label );
labelAnalysisAlgo.setInputIntensityImage( polystyrene );
labelAnalysisAlgo.setOutputAnalysis( analysis );
labelAnalysisAlgo.execute();

std::cout << "Area2d: " << areaMsr->value( 0 ) << std::endl;
std::cout << "inverseCircularity2d: " << inverseMsr->value( 0 ) << std::endl;
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"))

# Creates an analysis with Area2d and InverseCircularity2d measurements
analysis = imagedev.AnalysisMsr()
analysis.select(imagedev.native_measurements.Area2d)
analysis.select(imagedev.native_measurements.InverseCircularity2d)

label_analysis_algo = imagedev.LabelAnalysis()
label_analysis_algo.input_label_image = polystyrene_sep_label
label_analysis_algo.input_intensity_image = polystyrene
label_analysis_algo.output_analysis = analysis
label_analysis_algo.execute()

print("Area2d: ", analysis.get(imagedev.native_measurements.Area2d).value( 0 ) )
print("InverseCircularity2d: ", analysis.get(imagedev.native_measurements.InverseCircularity2d).value( 0 ) )
ImageView polystyrene_sep_label = Data.ReadVipImage(@"Data\images\polystyrene_sep_label.vip");
ImageView polystyrene = ViewIO.ReadImage(@"Data\images\polystyrene.tif");

// Creates an analysis with Area2d and InverseCircularity2d measurements
AnalysisMsr analysis = new AnalysisMsr();
Measurements.Area2d areaMsr = analysis.Select(NativeMeasurements.Area2d);
Measurements.InverseCircularity2d inverseMsr = analysis.Select(NativeMeasurements.InverseCircularity2d);

LabelAnalysis labelAnalysisAlgo = new LabelAnalysis
{
    inputLabelImage = polystyrene_sep_label,
    inputIntensityImage = polystyrene,
    outputAnalysis = analysis
};
labelAnalysisAlgo.Execute();
labelAnalysisAlgo.Dispose();

Console.WriteLine("Area2d: " + areaMsr.Value(0));
Console.WriteLine("InverseCircularity2d: " + inverseMsr.Value(0));

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" );

// Creates an analysis with Area2d and InverseCircularity2d measurements
AnalysisMsr::Ptr analysis( new AnalysisMsr() );
measurements::Area2d::Ptr areaMsr = analysis->select( NativeMeasurements::area2d );
measurements::InverseCircularity2d::Ptr inverseMsr = analysis->select( NativeMeasurements::inverseCircularity2d );

labelAnalysis( polystyrene_sep_label, polystyrene, analysis );

std::cout << "Area2d: " << areaMsr->value( 0 ) << std::endl;
std::cout << "inverseCircularity2d: " << inverseMsr->value( 0 ) << std::endl;
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"))

# Creates an analysis with Area2d and InverseCircularity2d measurements
analysis = imagedev.AnalysisMsr()
analysis.select(imagedev.native_measurements.Area2d)
analysis.select(imagedev.native_measurements.InverseCircularity2d)

result = imagedev.label_analysis( polystyrene_sep_label, polystyrene, analysis )

print("Area2d: ", result.get(imagedev.native_measurements.Area2d).value( 0 ) )
print("InverseCircularity2d: ", result.get(imagedev.native_measurements.InverseCircularity2d).value( 0 ) )
ImageView polystyrene_sep_label = Data.ReadVipImage(@"Data\images\polystyrene_sep_label.vip");
ImageView polystyrene = ViewIO.ReadImage(@"Data\images\polystyrene.tif");

// Creates an analysis with Area2d and InverseCircularity2d measurements
AnalysisMsr analysis = new AnalysisMsr();
Measurements.Area2d areaMsr = analysis.Select(NativeMeasurements.Area2d);
Measurements.InverseCircularity2d inverseMsr = analysis.Select(NativeMeasurements.InverseCircularity2d);

Processing.LabelAnalysis(polystyrene_sep_label, polystyrene, analysis);

Console.WriteLine("Area2d: " + areaMsr.Value(0));
Console.WriteLine("InverseCircularity2d: " + inverseMsr.Value(0));