SupervisedTextureClassification2d
            Performs a segmentation of a two-dimensional grayscale image, based on a texture model automatically built from a training input image.
Access to parameter description
For an introduction:
        
See also
		Access to parameter description
For an introduction:
- section Image Segmentation
 - section Supervised Texture Classification
 
See also
Function Syntax
This function returns a SupervisedTextureClassification2dOutput structure containing the outputLabelImage and outputMapImage output parameters.
                        
                    
// Output structure.
struct SupervisedTextureClassification2dOutput
{
    std::shared_ptr< iolink::ImageView > outputLabelImage;
    std::shared_ptr< iolink::ImageView > outputMapImage;
};
// Function prototype.
SupervisedTextureClassification2dOutput
supervisedTextureClassification2d( std::shared_ptr< iolink::ImageView > inputImage,
                                   std::shared_ptr< iolink::ImageView > inputTrainingImage,
                                   int32_t featureGroup,
                                   iolink::Vector2u32 radiusRange,
                                   uint32_t radiusStep,
                                   uint32_t coocRadius,
                                   SupervisedTextureClassification2d::CoocTextonShape coocTextonShape,
                                   uint32_t coocTextonSize,
                                   double minSeparationPercentage,
                                   SupervisedTextureClassification2d::OutputMapType outputMapType,
                                   std::shared_ptr< iolink::ImageView > outputLabelImage = NULL,
                                   std::shared_ptr< iolink::ImageView > outputMapImage = NULL );
                    
This function returns a tuple containing the output_label_image and output_map_image output parameters.
                        
                    
// Function prototype.
supervised_texture_classification_2d( input_image,
                                      input_training_image,
                                      feature_group = 31,
                                      radius_range = [2, 14],
                                      radius_step = 4,
                                      cooc_radius = 10,
                                      cooc_texton_shape = SupervisedTextureClassification2d.CoocTextonShape.SPHERE,
                                      cooc_texton_size = 4,
                                      min_separation_percentage = 3,
                                      output_map_type = SupervisedTextureClassification2d.OutputMapType.CLOSEST_DISTANCE,
                                      output_label_image = None,
                                      output_map_image = None )
                    
This function returns a SupervisedTextureClassification2dOutput structure containing the outputLabelImage and outputMapImage output parameters.
                        
                
/// Output structure of the SupervisedTextureClassification2d function.
public struct SupervisedTextureClassification2dOutput
{
    public IOLink.ImageView outputLabelImage;
    public IOLink.ImageView outputMapImage;
};
// Function prototype.
public static SupervisedTextureClassification2dOutput
SupervisedTextureClassification2d( IOLink.ImageView inputImage,
                                   IOLink.ImageView inputTrainingImage,
                                   Int32 featureGroup = 31,
                                   uint[] radiusRange = null,
                                   UInt32 radiusStep = 4,
                                   UInt32 coocRadius = 10,
                                   SupervisedTextureClassification2d.CoocTextonShape coocTextonShape = ImageDev.SupervisedTextureClassification2d.CoocTextonShape.SPHERE,
                                   UInt32 coocTextonSize = 4,
                                   double minSeparationPercentage = 3,
                                   SupervisedTextureClassification2d.OutputMapType outputMapType = ImageDev.SupervisedTextureClassification2d.OutputMapType.CLOSEST_DISTANCE,
                                   IOLink.ImageView outputLabelImage = null,
                                   IOLink.ImageView outputMapImage = null );
                    Class Syntax
Parameters
| Class Name | SupervisedTextureClassification2d | 
|---|
| Parameter Name | Description | Type | Supported Values | Default Value | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
![]()  | 
  inputImage    | 
 The input grayscale image to segment. | Image | Grayscale | nullptr | ||||||||||
![]()  | 
  inputTrainingImage    | 
 The input label training image (16 or 32 bits) where each label represents a class sample for the training step. | Image | Label | nullptr | ||||||||||
![]()  | 
  featureGroup    | 
 The groups of textural features to compute. This list defines all the textural attributes proposed for performing the classification.
  | 
MultipleChoice | DIRECTIONAL_COOCCURRENCE | ROTATION_INVARIANT_COOCCURRENCE | FIRST_ORDER_STATISTICS | HISTOGRAM_STATISTICS | INTENSITY | |||||||||||
![]()  | 
  radiusRange    | 
 The minimum and maximum radius, in pixels, of the circular neighborhoods used for computing textural features. | Vector2u32 | >=1 | {2, 14} | ||||||||||
![]()  | 
  radiusStep    | 
 The step in pixels used to define the set of radii between minimum and maximum. The maximum radius is systematically added to the radius list. | UInt32 | >=1 | 4 | ||||||||||
![]()  | 
  coocRadius    | 
 The radius, in pixels, of the circular neighborhood used by the co-occurrence features. This parameter is ignored if none of the co-occurrence feature groups is selected. | UInt32 | >=1 | 10 | ||||||||||
![]()  | 
  coocTextonShape    | 
 The shape of the co-occurrence texton (the pattern defined by the set of co-occurrence vectors). This parameter is ignored if none of the co-occurrence feature groups is selected.
 The texton shape represents the distribution of points around the target point for computing the co-occurrence matrices. Associated to the texton size, it defines the set of vectors that are used for computing co-occurrence features. For instance, in 2D, a cube shape of size 3 defines the co-occurrence vectors (-3, -3), (0, -3), (3, -3), (-3, 0), (3, 0), (-3, 3), (0, 3) and (3, 3). 
  | 
Enumeration | SPHERE | |||||||||||
![]()  | 
  coocTextonSize    | 
 The size, in pixels, of the texton shape for co-occurrence features. This parameter is ignored if none of the co-occurrence feature groups is selected.
 This size is constrained by the radius parameter. The constraint depends on the texton shape. For instance, with a square texton, the texton size cannot exceed the rounded value of $radius \times \sqrt{2}$.  | 
UInt32 | >=1 | 4 | ||||||||||
![]()  | 
  minSeparationPercentage    | 
 This parameter controls the rejection criteria of the feature selection algorithm (FS).
 A measure is rejected if its contribution does not increase the separation power of the classification model enough. This ratio indicates the minimal relative growth required to keep a measure. More information is available in the Feature Selection section. This value must be greater than or equal to 0.0.  | 
Float64 | [0, 100] | 3 | ||||||||||
![]()  | 
  outputMapType    | 
 The type of uncertainty map image to compute.
  | 
Enumeration | CLOSEST_DISTANCE | |||||||||||
![]()  | 
  outputLabelImage    | 
 The output label image representing the texture classification result. Its dimensions and type are forced to the same values as the training input. | Image | nullptr | |||||||||||
![]()  | 
  outputMapImage    | 
 The output map image. Its dimensions are forced to the same values as the training image. In CLASS_DISTANCE mode, its number of channels is equal to the number of classes defined in the training image. Its data type is forced to floating point. | Image | nullptr | |||||||||||
Object Examples
std::shared_ptr< iolink::ImageView > polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" );
auto polystyrene_sep_label = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene_sep_label.vip" );
SupervisedTextureClassification2d supervisedTextureClassification2dAlgo;
supervisedTextureClassification2dAlgo.setInputImage( polystyrene );
supervisedTextureClassification2dAlgo.setInputTrainingImage( polystyrene_sep_label );
supervisedTextureClassification2dAlgo.setFeatureGroup( 4 );
supervisedTextureClassification2dAlgo.setRadiusRange( {2, 4} );
supervisedTextureClassification2dAlgo.setRadiusStep( 4 );
supervisedTextureClassification2dAlgo.setCoocRadius( 4 );
supervisedTextureClassification2dAlgo.setCoocTextonShape( SupervisedTextureClassification2d::CoocTextonShape::CUBE );
supervisedTextureClassification2dAlgo.setCoocTextonSize( 4 );
supervisedTextureClassification2dAlgo.setMinSeparationPercentage( 3 );
supervisedTextureClassification2dAlgo.setOutputMapType( SupervisedTextureClassification2d::OutputMapType::CLOSEST_DISTANCE );
supervisedTextureClassification2dAlgo.execute();
std::cout << "outputLabelImage:" << supervisedTextureClassification2dAlgo.outputLabelImage()->toString();
std::cout << "outputMapImage:" << supervisedTextureClassification2dAlgo.outputMapImage()->toString();
            
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif"))
polystyrene_sep_label = imagedev.read_vip_image(imagedev_data.get_image_path("polystyrene_sep_label.vip"))
supervised_texture_classification_2d_algo = imagedev.SupervisedTextureClassification2d()
supervised_texture_classification_2d_algo.input_image = polystyrene
supervised_texture_classification_2d_algo.input_training_image = polystyrene_sep_label
supervised_texture_classification_2d_algo.feature_group = 4
supervised_texture_classification_2d_algo.radius_range = [2, 4]
supervised_texture_classification_2d_algo.radius_step = 4
supervised_texture_classification_2d_algo.cooc_radius = 4
supervised_texture_classification_2d_algo.cooc_texton_shape = imagedev.SupervisedTextureClassification2d.CUBE
supervised_texture_classification_2d_algo.cooc_texton_size = 4
supervised_texture_classification_2d_algo.min_separation_percentage = 3
supervised_texture_classification_2d_algo.output_map_type = imagedev.SupervisedTextureClassification2d.CLOSEST_DISTANCE
supervised_texture_classification_2d_algo.execute()
print( "output_label_image:", str( supervised_texture_classification_2d_algo.output_label_image ) );
print( "output_map_image:", str( supervised_texture_classification_2d_algo.output_map_image ) );
            
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" );
ImageView polystyrene_sep_label = Data.ReadVipImage( @"Data/images/polystyrene_sep_label.vip" );
SupervisedTextureClassification2d supervisedTextureClassification2dAlgo = new SupervisedTextureClassification2d
{
    inputImage = polystyrene,
    inputTrainingImage = polystyrene_sep_label,
    featureGroup = 4,
    radiusRange = new uint[]{2, 4},
    radiusStep = 4,
    coocRadius = 4,
    coocTextonShape = SupervisedTextureClassification2d.CoocTextonShape.CUBE,
    coocTextonSize = 4,
    minSeparationPercentage = 3,
    outputMapType = SupervisedTextureClassification2d.OutputMapType.CLOSEST_DISTANCE
};
supervisedTextureClassification2dAlgo.Execute();
Console.WriteLine( "outputLabelImage:" + supervisedTextureClassification2dAlgo.outputLabelImage.ToString() );
Console.WriteLine( "outputMapImage:" + supervisedTextureClassification2dAlgo.outputMapImage.ToString() );
            Function Examples
std::shared_ptr< iolink::ImageView > polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" );
auto polystyrene_sep_label = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene_sep_label.vip" );
auto result = supervisedTextureClassification2d( polystyrene, polystyrene_sep_label, 4, {2, 4}, 4, 4, SupervisedTextureClassification2d::CoocTextonShape::CUBE, 4, 3, SupervisedTextureClassification2d::OutputMapType::CLOSEST_DISTANCE );
std::cout << "outputLabelImage:" << result.outputLabelImage->toString();
std::cout << "outputMapImage:" << result.outputMapImage->toString();
            
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif"))
polystyrene_sep_label = imagedev.read_vip_image(imagedev_data.get_image_path("polystyrene_sep_label.vip"))
result_output_label_image, result_output_map_image = imagedev.supervised_texture_classification_2d( polystyrene, polystyrene_sep_label, 4, [2, 4], 4, 4, imagedev.SupervisedTextureClassification2d.CUBE, 4, 3, imagedev.SupervisedTextureClassification2d.CLOSEST_DISTANCE )
print( "output_label_image:", str( result_output_label_image ) );
print( "output_map_image:", str( result_output_map_image ) );
            
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" );
ImageView polystyrene_sep_label = Data.ReadVipImage( @"Data/images/polystyrene_sep_label.vip" );
Processing.SupervisedTextureClassification2dOutput result = Processing.SupervisedTextureClassification2d( polystyrene, polystyrene_sep_label, 4, new uint[]{2, 4}, 4, 4, SupervisedTextureClassification2d.CoocTextonShape.CUBE, 4, 3, SupervisedTextureClassification2d.OutputMapType.CLOSEST_DISTANCE );
Console.WriteLine( "outputLabelImage:" + result.outputLabelImage.ToString() );
Console.WriteLine( "outputMapImage:" + result.outputMapImage.ToString() );
            
