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:
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:
- PixelCount: the number of pixels or voxels representing each label and having a non-zero value in the mask image.
- TotalPixelCount: the number of pixels or voxels of the mask. If no mask is provided, it represents
the number of pixels or voxels of the entire image:
2D case without mask: $TotalPixelCount = gx \times gy$
3D case without mask: $TotalPixelCount = gx \times gy \times gz$ - Volume: the 3D volume or 2D area of each label, expressed in world coordinates.
- TotalVolume: the 3D volume or 2D area of the mask, expressed in world coordinates. If no mask is
provided, it represents the area or volume of the entire image.
2D case: $TotalVolume = TotalPixelCount \times cx \times cy$
3D case: $TotalVolume = TotalPixelCount \times cx \times cy \times cz $ - VolumeFraction: the proportion of the image occupied by each label.
$VolumeFraction = PixelCount/TotalPixelCount$
- gx, gy and gz are the image dimensions along each axis, in pixel units.
- cx, cy and cz is the voxel size along each axis, in world coordinates.
Function Syntax
This function returns outputMeasurement.
// Function prototype
VolumeFractionByLabelMsr::Ptr volumeFractionByLabel( std::shared_ptr< iolink::ImageView > inputObjectImage, std::shared_ptr< iolink::ImageView > inputMaskImage, VolumeFractionByLabelMsr::Ptr outputMeasurement = NULL );
This function returns outputMeasurement.
// Function prototype. volume_fraction_by_label( input_object_image, input_mask_image, output_measurement = None )
This function returns outputMeasurement.
// 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 | |
---|---|---|---|---|---|
inputObjectImage |
The binary or label input image. | Image | Binary or Label | nullptr | |
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 | |
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( "volumeFraction: ", str( 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: ", str( 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 ) );