AutoSegmentation3Phases
            Performs an automatic 2-level segmentation of a grayscale image.
Access to parameter description
For an introduction:
Three methods of classification are available: Entropy, Factorisation, or Moments. These methods are detailed in the AutoThresholdingBright documentation.
        
The computed threshold is returned in the AutoSegmentation3PhasesMsr object.
        
The output image is a label image with 2 non-zero levels.
        
See also
		Access to parameter description
For an introduction:
- section Image Segmentation
 - section Unsupervised Classification
 - section AutoThresholdingBright
 
Three methods of classification are available: Entropy, Factorisation, or Moments. These methods are detailed in the AutoThresholdingBright documentation.
The computed threshold is returned in the AutoSegmentation3PhasesMsr object.
The output image is a label image with 2 non-zero levels.
See also
Function Syntax
This function returns a AutoSegmentation3PhasesOutput structure containing the outputLabelImage and outputMeasurement output parameters.
                        
                    
// Output structure.
struct AutoSegmentation3PhasesOutput
{
    std::shared_ptr< iolink::ImageView > outputLabelImage;
    AutoSegmentation3PhasesMsr::Ptr outputMeasurement;
};
// Function prototype.
AutoSegmentation3PhasesOutput
autoSegmentation3Phases( std::shared_ptr< iolink::ImageView > inputGrayImage,
                         AutoSegmentation3Phases::RangeMode rangeMode,
                         iolink::Vector2d intensityInputRange,
                         AutoSegmentation3Phases::ThresholdCriterion thresholdCriterion,
                         std::shared_ptr< iolink::ImageView > outputLabelImage = NULL,
                         AutoSegmentation3PhasesMsr::Ptr outputMeasurement = NULL );
                    
This function returns a tuple containing the output_label_image and output_measurement output parameters.
                        
                    
// Function prototype.
auto_segmentation3_phases( input_gray_image,
                           range_mode = AutoSegmentation3Phases.RangeMode.MIN_MAX,
                           intensity_input_range = [0, 255],
                           threshold_criterion = AutoSegmentation3Phases.ThresholdCriterion.ENTROPY,
                           output_label_image = None,
                           output_measurement = None )
                    
This function returns a AutoSegmentation3PhasesOutput structure containing the outputLabelImage and outputMeasurement output parameters.
                        
                
/// Output structure of the AutoSegmentation3Phases function.
public struct AutoSegmentation3PhasesOutput
{
    public IOLink.ImageView outputLabelImage;
    public AutoSegmentation3PhasesMsr outputMeasurement;
};
// Function prototype.
public static AutoSegmentation3PhasesOutput
AutoSegmentation3Phases( IOLink.ImageView inputGrayImage,
                         AutoSegmentation3Phases.RangeMode rangeMode = ImageDev.AutoSegmentation3Phases.RangeMode.MIN_MAX,
                         double[] intensityInputRange = null,
                         AutoSegmentation3Phases.ThresholdCriterion thresholdCriterion = ImageDev.AutoSegmentation3Phases.ThresholdCriterion.ENTROPY,
                         IOLink.ImageView outputLabelImage = null,
                         AutoSegmentation3PhasesMsr outputMeasurement = null );
                    Class Syntax
Parameters
| Class Name | AutoSegmentation3Phases | 
|---|
| Parameter Name | Description | Type | Supported Values | Default Value | |||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
![]()  | 
  inputGrayImage    | 
 The input grayscale image. | Image | Grayscale | nullptr | ||||||
![]()  | 
  rangeMode    | 
 The way to determine the input intensity range.
  | 
Enumeration | MIN_MAX | |||||||
![]()  | 
  intensityInputRange    | 
 The input intensity range [a,b] inside which the threshold is searched. This parameter is ignored if the range mode is set to MIN_MAX. | Vector2d | Any value | {0.f, 255.f} | ||||||
![]()  | 
  thresholdCriterion    | 
 The criterion to compute the threshold from the histogram.
  | 
Enumeration | ENTROPY | |||||||
![]()  | 
  outputLabelImage    | 
 The output binary image. Its dimensions are forced to the same values as the input. | Image | nullptr | |||||||
![]()  | 
  outputMeasurement    | 
 The computed threshold values. | AutoSegmentation3PhasesMsr | nullptr | |||||||
Object Examples
std::shared_ptr< iolink::ImageView > polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" );
AutoSegmentation3Phases autoSegmentation3PhasesAlgo;
autoSegmentation3PhasesAlgo.setInputGrayImage( polystyrene );
autoSegmentation3PhasesAlgo.setRangeMode( AutoSegmentation3Phases::RangeMode::MIN_MAX );
autoSegmentation3PhasesAlgo.setIntensityInputRange( {0, 255} );
autoSegmentation3PhasesAlgo.setThresholdCriterion( AutoSegmentation3Phases::ThresholdCriterion::ENTROPY );
autoSegmentation3PhasesAlgo.execute();
std::cout << "outputLabelImage:" << autoSegmentation3PhasesAlgo.outputLabelImage()->toString();
std::cout << "thresholdLow: " << autoSegmentation3PhasesAlgo.outputMeasurement()->thresholdLow( 0 ) ;
            
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif"))
auto_segmentation3_phases_algo = imagedev.AutoSegmentation3Phases()
auto_segmentation3_phases_algo.input_gray_image = polystyrene
auto_segmentation3_phases_algo.range_mode = imagedev.AutoSegmentation3Phases.MIN_MAX
auto_segmentation3_phases_algo.intensity_input_range = [0, 255]
auto_segmentation3_phases_algo.threshold_criterion = imagedev.AutoSegmentation3Phases.ENTROPY
auto_segmentation3_phases_algo.execute()
print( "output_label_image:", str( auto_segmentation3_phases_algo.output_label_image ) );
print( 
print("thresholdLow: ", auto_segmentation3_phases_algo.output_measurement.threshold_low( 0 ) ) );
            
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" );
AutoSegmentation3Phases autoSegmentation3PhasesAlgo = new AutoSegmentation3Phases
{
    inputGrayImage = polystyrene,
    rangeMode = AutoSegmentation3Phases.RangeMode.MIN_MAX,
    intensityInputRange = new double[]{0, 255},
    thresholdCriterion = AutoSegmentation3Phases.ThresholdCriterion.ENTROPY
};
autoSegmentation3PhasesAlgo.Execute();
Console.WriteLine( "outputLabelImage:" + autoSegmentation3PhasesAlgo.outputLabelImage.ToString() );
Console.WriteLine( "thresholdLow: " + autoSegmentation3PhasesAlgo.outputMeasurement.thresholdLow( 0 ) );
            Function Examples
std::shared_ptr< iolink::ImageView > polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" );
auto result = autoSegmentation3Phases( polystyrene, AutoSegmentation3Phases::RangeMode::MIN_MAX, {0, 255}, AutoSegmentation3Phases::ThresholdCriterion::ENTROPY );
std::cout << "outputLabelImage:" << result.outputLabelImage->toString();
std::cout << "thresholdLow: " << result.outputMeasurement->thresholdLow( 0 ) ;
            
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif"))
result_output_label_image, result_output_measurement = imagedev.auto_segmentation3_phases( polystyrene, imagedev.AutoSegmentation3Phases.MIN_MAX, [0, 255], imagedev.AutoSegmentation3Phases.ENTROPY )
print( "output_label_image:", str( result_output_label_image ) );
print( "thresholdLow: ", result_output_measurement.threshold_low( 0 ) );
            
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" );
Processing.AutoSegmentation3PhasesOutput result = Processing.AutoSegmentation3Phases( polystyrene, AutoSegmentation3Phases.RangeMode.MIN_MAX, new double[]{0, 255}, AutoSegmentation3Phases.ThresholdCriterion.ENTROPY );
Console.WriteLine( "outputLabelImage:" + result.outputLabelImage.ToString() );
Console.WriteLine(  "thresholdLow: " + result.outputMeasurement.thresholdLow( 0 )  );
            
