ImageDev

AutoIntensityClassification

Classifies all pixels of a grayscale image using the k-means clustering method.

Access to parameter description

As an introduction: This algorithm segments the input image into a user-defined number of regions and assigns the same label to pixels sharing similar intensity characteristics. It implements the k-means clustering method, which is a standard for performing unsupervised classification into a known number of classes $K$.

Let $S$ denote the set of image intensities. The input image can be a color image, so $S$ is a set of vectors in which each element corresponds to an image channel. A label is assigned to each pixel of the output image, corresponding to the class assigned to its input intensity vector.

$K$ is the number of classes to obtain, which is the main parameter of the algorithm. The size of the subset $S'$ is also a parameter of the algorithm, given as a percentage of the input data.

Reference:
S. P. Lloyd, "Least square quantization in PCM", IEEE Transactions on Information Theory, vol. 28, no 2, pp. 129-137, 1982.

See also

Function Syntax

This function returns outputLabelImage.
// Function prototype
std::shared_ptr< iolink::ImageView > autoIntensityClassification( std::shared_ptr< iolink::ImageView > inputImage, int32_t classNumber, int32_t dataPercentage, std::shared_ptr< iolink::ImageView > outputLabelImage = NULL );
This function returns outputLabelImage.
// Function prototype.
auto_intensity_classification( input_image,
                               class_number = 2,
                               data_percentage = 100,
                               output_label_image = None )
This function returns outputLabelImage.
// Function prototype.
public static IOLink.ImageView
AutoIntensityClassification( IOLink.ImageView inputImage,
                             Int32 classNumber = 2,
                             Int32 dataPercentage = 100,
                             IOLink.ImageView outputLabelImage = null );

Class Syntax

Parameters

Class Name AutoIntensityClassification

Parameter Name Description Type Supported Values Default Value
input
inputImage
The input image. Image Grayscale or Multispectral nullptr
input
classNumber
The number of classes to detect (the label number of the output). Int32 >=0 2
input
dataPercentage
The data percentage used for pre-computing the classification. Int32 [1, 100] 100
output
outputLabelImage
The output label image where a one label represents one class. Image nullptr

Object Examples

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

AutoIntensityClassification autoIntensityClassificationAlgo;
autoIntensityClassificationAlgo.setInputImage( foam );
autoIntensityClassificationAlgo.setClassNumber( 2 );
autoIntensityClassificationAlgo.setDataPercentage( 100 );
autoIntensityClassificationAlgo.execute();

std::cout << "outputLabelImage:" << autoIntensityClassificationAlgo.outputLabelImage()->toString();
foam = imagedev.read_vip_image(imagedev_data.get_image_path("foam.vip"))

auto_intensity_classification_algo = imagedev.AutoIntensityClassification()
auto_intensity_classification_algo.input_image = foam
auto_intensity_classification_algo.class_number = 2
auto_intensity_classification_algo.data_percentage = 100
auto_intensity_classification_algo.execute()

print( "output_label_image:", str( auto_intensity_classification_algo.output_label_image ) )
ImageView foam = Data.ReadVipImage( @"Data/images/foam.vip" );

AutoIntensityClassification autoIntensityClassificationAlgo = new AutoIntensityClassification
{
    inputImage = foam,
    classNumber = 2,
    dataPercentage = 100
};
autoIntensityClassificationAlgo.Execute();

Console.WriteLine( "outputLabelImage:" + autoIntensityClassificationAlgo.outputLabelImage.ToString() );

Function Examples

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

auto result = autoIntensityClassification( foam, 2, 100 );

std::cout << "outputLabelImage:" << result->toString();
foam = imagedev.read_vip_image(imagedev_data.get_image_path("foam.vip"))

result = imagedev.auto_intensity_classification( foam, 2, 100 )

print( "output_label_image:", str( result ) )
ImageView foam = Data.ReadVipImage( @"Data/images/foam.vip" );

IOLink.ImageView result = Processing.AutoIntensityClassification( foam, 2, 100 );

Console.WriteLine( "outputLabelImage:" + result.ToString() );