Cooccurrence2d
Provides texture indicators, also known as Haralick features, based on the computation of co-occurrence matrix.
Access to parameter description
This algorithm provides some information regarding the texture by performing the computation of a co-occurrence matrix. It allows the classification of pairs of pixels by their gray level, along a directional offset $(dx,dy)$.
The co-occurrence matrix components are given by $$ M(i,j)=number\left(\{x,y\}/(I(x,y)=i)\cap(I(x+dx,y+dy)=j)\right) $$ where $I(x,y)$ is the image gray level for $(x,y)$ coordinates.
This formulation means that for a given pair $(i,j)$, $M(i,j)$ contains the number of pixels verifying $I(x,y)=i$ and $I(x+dx,y+dy)=j$.
This matrix is made symmetric and normalized such as $$ \forall(i,j),M(i,j)=M(j,i) ~\mbox{and} \sum_{i,j=1}^{N}M(i,j)=1 $$ These operations are independent of the image size and reveal some properties on a direction and its symmetry.
Thirteen indicators are computed from this matrix:
In addition, this algorithm returns the number of image pixels used for computation in the result object.
References
R.Haralick , K.Shanmugam & I.Dinstein "Textural features for image classification". IEEE Transactions on Systems, Man, and Cybernetics. vol. 3, no. 6, pp 610-621, Oct. 1973.
See also
Access to parameter description
This algorithm provides some information regarding the texture by performing the computation of a co-occurrence matrix. It allows the classification of pairs of pixels by their gray level, along a directional offset $(dx,dy)$.
The co-occurrence matrix components are given by $$ M(i,j)=number\left(\{x,y\}/(I(x,y)=i)\cap(I(x+dx,y+dy)=j)\right) $$ where $I(x,y)$ is the image gray level for $(x,y)$ coordinates.
This formulation means that for a given pair $(i,j)$, $M(i,j)$ contains the number of pixels verifying $I(x,y)=i$ and $I(x+dx,y+dy)=j$.
This matrix is made symmetric and normalized such as $$ \forall(i,j),M(i,j)=M(j,i) ~\mbox{and} \sum_{i,j=1}^{N}M(i,j)=1 $$ These operations are independent of the image size and reveal some properties on a direction and its symmetry.
Thirteen indicators are computed from this matrix:
- An angular second moment indicator (ASM), also called uniformity. This indicator takes high values when image pixels present strong local uniformity. $$ ASM= \sum_{i,j=1}^{N}{M(i,j)}^2 $$
- A contrast indicator (Con). This indicator takes high values for great gray level variations. $$ Con= \sum_{i,j=1}^{N}M(i,j)\times(i-j)^2 $$
- A correlation indicator (Cor) which measures the dependency between gray levels
and those of neighbouring pixels.
$$ Cor= \sum_{i,j=1}^{N}M(i,j)\times\frac{(i-\mu)(j-\mu)}{\sigma^2} $$ - A variance indicator (SSV) also called sum of squares. This indicator measures the dispersion of the combination of gray levels and their neighbor pixels around the mean. $$ SSV=\sigma=\sum_{i,j=1}^{N}M(i,j)\times(i-\mu)^2 $$
- An inverse difference moment (IDM) also called homogeneity $$ IDM= \sum_{i,j=1}^{N}\frac{M(i,j)}{1+(i-j)^2} $$
- A sum average indicator (SAv) $$ SAv=\sum_{i,j=1}^{N}M(i,j)\times(i+j) $$
- A sum variance indicator (SVa) $$ SVa=\sum_{i,j=1}^{N}M(i,j)\times(i+j-SAv)^2 $$
- A sum entropy indicator (SEn) $$ SEn=-\sum_{k=2}^{2N}M_{x+y}(k)\times log(M_{x+y}(k)) ~\mbox{where}~ M_{x+y}(k)=\sum_{i+j=k}M(i,j) $$
- An entropy indicator (Ent) $$ Ent=-\sum_{i,j=1}^{N}M(i,j)\times log(M(i,j)) $$
- A difference variance indicator (DVa) $$ DVa=variance(M_{x-y}) ~\mbox{where}~ M_{x-y}(k)=\sum_{|i-j|=k}M(i,j) $$
- A difference entropy indicator (DEn) $$ DEn=-\sum_{k=0}^{N-1}M_{x-y}(k)\times log(M_{x-y}(k)) $$
- Two information measurements of correlation (IC1 and IC2) $$ IC1=\frac{HXY-HXY1}{max(HX,HY)} ~\mbox{where}~ IC2=\sqrt{1-e^{-2\times|HXY2-HXY|}} $$
- where:
$$ \mu=\sum_{i,j=1}^{N}i\times M(i,j) ~\mbox{and}~
\sigma^2=\sum_{i,j=1}^{N}M(i,j)\times(i-\mu)^2 $$
- where HX and HY are entropies of $M_x$ and $M_y$ such as
$$ M_x(i)=\sum_{j=1}^{N}M(i,j) ~\mbox{and}~ M_y(j)=\sum_{i=1}^{N}M(i,j) $$
and
$$ HXY=-\sum_{i,j=1}^{N}M(i,j)\times log(M(i,j)) $$
$$ HXY1=-\sum_{i,j=1}^{N}M(i,j)\times log(M_x(i)\times M_y(j)) $$
$$ HXY2=-\sum_{i,j=1}^{N}M_x(i)\times M_y(j)\times log(M_x(i)\times M_y(j)) $$
In addition, this algorithm returns the number of image pixels used for computation in the result object.
References
R.Haralick , K.Shanmugam & I.Dinstein "Textural features for image classification". IEEE Transactions on Systems, Man, and Cybernetics. vol. 3, no. 6, pp 610-621, Oct. 1973.
See also
Function Syntax
This function returns outputMeasurement.
// Function prototype
CoocurrrenceMsr::Ptr cooccurrence2d( std::shared_ptr< iolink::ImageView > inputImage, std::shared_ptr< iolink::ImageView > inputMaskImage, int32_t offsetX, int32_t offsetY, CoocurrrenceMsr::Ptr outputMeasurement = NULL );
This function returns outputMeasurement.
// Function prototype. cooccurrence_2d( input_image, input_mask_image, offset_x = 1, offset_y = 0, output_measurement = None )
This function returns outputMeasurement.
// Function prototype. public static CoocurrrenceMsr Cooccurrence2d( IOLink.ImageView inputImage, IOLink.ImageView inputMaskImage, Int32 offsetX = 1, Int32 offsetY = 0, CoocurrrenceMsr outputMeasurement = null );
Class Syntax
Parameters
Class Name | Cooccurrence2d |
---|
Parameter Name | Description | Type | Supported Values | Default Value | |
---|---|---|---|---|---|
inputImage |
The input image. | Image | Binary, Label, Grayscale or Multispectral | nullptr | |
inputMaskImage |
The binary mask image where co-occurrence is computed. If it equals null, computations are performed on all pixels of the input image. This image must have the same dimensions as the input image. | Image | Binary | nullptr | |
offsetX |
The X offset defining the co-occurrence vector. | Int32 | Any value | 1 | |
offsetY |
The Y offset defining the co-occurrence vector. | Int32 | Any value | 0 | |
outputMeasurement |
The output measurement result object containing the haralick features. | CoocurrrenceMsr | nullptr |
Object Examples
std::shared_ptr< iolink::ImageView > polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" ); auto polystyrene_mask = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene_mask.vip" ); Cooccurrence2d cooccurrence2dAlgo; cooccurrence2dAlgo.setInputImage( polystyrene ); cooccurrence2dAlgo.setInputMaskImage( polystyrene_mask ); cooccurrence2dAlgo.setOffsetX( 1 ); cooccurrence2dAlgo.setOffsetY( 0 ); cooccurrence2dAlgo.execute(); std::cout << "pixelCount: " << cooccurrence2dAlgo.outputMeasurement()->pixelCount( 0 ) ;
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif")) polystyrene_mask = imagedev.read_vip_image(imagedev_data.get_image_path("polystyrene_mask.vip")) cooccurrence_2d_algo = imagedev.Cooccurrence2d() cooccurrence_2d_algo.input_image = polystyrene cooccurrence_2d_algo.input_mask_image = polystyrene_mask cooccurrence_2d_algo.offset_x = 1 cooccurrence_2d_algo.offset_y = 0 cooccurrence_2d_algo.execute() print( "pixelCount: ", str( cooccurrence_2d_algo.output_measurement.pixel_count( 0 ) ) )
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" ); ImageView polystyrene_mask = Data.ReadVipImage( @"Data/images/polystyrene_mask.vip" ); Cooccurrence2d cooccurrence2dAlgo = new Cooccurrence2d { inputImage = polystyrene, inputMaskImage = polystyrene_mask, offsetX = 1, offsetY = 0 }; cooccurrence2dAlgo.Execute(); Console.WriteLine( "pixelCount: " + cooccurrence2dAlgo.outputMeasurement.pixelCount( 0 ) );
Function Examples
std::shared_ptr< iolink::ImageView > polystyrene = ioformat::readImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene.tif" ); auto polystyrene_mask = readVipImage( std::string( IMAGEDEVDATA_IMAGES_FOLDER ) + "polystyrene_mask.vip" ); auto result = cooccurrence2d( polystyrene, polystyrene_mask, 1, 0 ); std::cout << "pixelCount: " << result->pixelCount( 0 ) ;
polystyrene = ioformat.read_image(imagedev_data.get_image_path("polystyrene.tif")) polystyrene_mask = imagedev.read_vip_image(imagedev_data.get_image_path("polystyrene_mask.vip")) result = imagedev.cooccurrence_2d( polystyrene, polystyrene_mask, 1, 0 ) print( "pixelCount: ", str( result.pixel_count( 0 ) ) )
ImageView polystyrene = ViewIO.ReadImage( @"Data/images/polystyrene.tif" ); ImageView polystyrene_mask = Data.ReadVipImage( @"Data/images/polystyrene_mask.vip" ); CoocurrrenceMsr result = Processing.Cooccurrence2d( polystyrene, polystyrene_mask, 1, 0 ); Console.WriteLine( "pixelCount: " + result.pixelCount( 0 ) );