ImageDev

VolumeFractionByLabel

Computes the volume fraction occupied by each object or region of a segmented image.

Access to parameter description

For an introduction: section Image Analysis.

This algorithm computes the volume fraction of a binary or label image; a mask can be used or not used. The mask input is optional. If no mask is provided, the entire image is considered as the mask.

It outputs a measurement object indexed by label (index 0 corresponds to label 1) and, in case of a time series, by time step. It contains the following measurements: where: See also

Function Syntax

This function returns the outputMeasurement output parameter.
// Function prototype.
VolumeFractionByLabelMsr::Ptr
volumeFractionByLabel( std::shared_ptr< iolink::ImageView > inputObjectImage,
                       std::shared_ptr< iolink::ImageView > inputMaskImage,
                       VolumeFractionByLabelMsr::Ptr outputMeasurement = NULL );
This function returns the outputMeasurement output parameter.
// Function prototype.
volume_fraction_by_label( input_object_image, input_mask_image, output_measurement = None )
This function returns the outputMeasurement output parameter.
// Function prototype.
public static VolumeFractionByLabelMsr
VolumeFractionByLabel( IOLink.ImageView inputObjectImage,
                       IOLink.ImageView inputMaskImage,
                       VolumeFractionByLabelMsr outputMeasurement = null );

Class Syntax

Parameters

Class Name VolumeFractionByLabel

Parameter Name Description Type Supported Values Default Value
input
inputObjectImage
The binary or label input image. Image Binary or Label nullptr
input
inputMaskImage
The binary input image used as a mask (optional). Pixels having a zero value in the mask are not taken into account in the computations. If equal to null, the entire input image is considered as the mask. This image must have same dimensions as the main input image. Image Binary nullptr
output
outputMeasurement
The output measurement results for each label. VolumeFractionByLabelMsr nullptr

Object Examples

auto polystyrene_sep_label = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene_sep_label.vip" );
auto polystyrene_sep = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene_sep.vip" );

VolumeFractionByLabel volumeFractionByLabelAlgo;
volumeFractionByLabelAlgo.setInputObjectImage( polystyrene_sep_label );
volumeFractionByLabelAlgo.setInputMaskImage( polystyrene_sep );
volumeFractionByLabelAlgo.execute();

std::cout << "volumeFraction: " << volumeFractionByLabelAlgo.outputMeasurement()->volumeFraction( 0 , 0 ) ;
polystyrene_sep_label = imagedev.read_vip_image(imagedev_data.get_image_path("polystyrene_sep_label.vip"))
polystyrene_sep = imagedev.read_vip_image(imagedev_data.get_image_path("polystyrene_sep.vip"))

volume_fraction_by_label_algo = imagedev.VolumeFractionByLabel()
volume_fraction_by_label_algo.input_object_image = polystyrene_sep_label
volume_fraction_by_label_algo.input_mask_image = polystyrene_sep
volume_fraction_by_label_algo.execute()

print( 
print("volumeFraction: ", volume_fraction_by_label_algo.output_measurement.volume_fraction( 0 , 0 ) ) );
ImageView polystyrene_sep_label = Data.ReadVipImage( @"Data/images/polystyrene_sep_label.vip" );
ImageView polystyrene_sep = Data.ReadVipImage( @"Data/images/polystyrene_sep.vip" );

VolumeFractionByLabel volumeFractionByLabelAlgo = new VolumeFractionByLabel
{
    inputObjectImage = polystyrene_sep_label,
    inputMaskImage = polystyrene_sep
};
volumeFractionByLabelAlgo.Execute();

Console.WriteLine( "volumeFraction: " + volumeFractionByLabelAlgo.outputMeasurement.volumeFraction( 0 , 0 ) );

Function Examples

auto polystyrene_sep_label = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene_sep_label.vip" );
auto polystyrene_sep = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene_sep.vip" );

auto result = volumeFractionByLabel( polystyrene_sep_label, polystyrene_sep );

std::cout << "volumeFraction: " << result->volumeFraction( 0 , 0 ) ;
polystyrene_sep_label = imagedev.read_vip_image(imagedev_data.get_image_path("polystyrene_sep_label.vip"))
polystyrene_sep = imagedev.read_vip_image(imagedev_data.get_image_path("polystyrene_sep.vip"))

result = imagedev.volume_fraction_by_label( polystyrene_sep_label, polystyrene_sep )

print( "volumeFraction: ", result.volume_fraction( 0 , 0 ) );
ImageView polystyrene_sep_label = Data.ReadVipImage( @"Data/images/polystyrene_sep_label.vip" );
ImageView polystyrene_sep = Data.ReadVipImage( @"Data/images/polystyrene_sep.vip" );

VolumeFractionByLabelMsr result = Processing.VolumeFractionByLabel( polystyrene_sep_label, polystyrene_sep );

Console.WriteLine(  "volumeFraction: " + result.volumeFraction( 0 , 0 )  );