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({x,y}/(I(x,y)=i)∩(I(x+dx,y+dy)=j)) 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 ∀(i,j),M(i,j)=M(j,i) andN∑i,j=1M(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({x,y}/(I(x,y)=i)∩(I(x+dx,y+dy)=j)) 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 ∀(i,j),M(i,j)=M(j,i) andN∑i,j=1M(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=N∑i,j=1M(i,j)2
- A contrast indicator (Con). This indicator takes high values for great gray level variations. Con=N∑i,j=1M(i,j)×(i−j)2
- A correlation indicator (Cor) which measures the dependency between gray levels
and those of neighbouring pixels.
Cor=N∑i,j=1M(i,j)×(i−μ)(j−μ)σ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=σ=N∑i,j=1M(i,j)×(i−μ)2
- An inverse difference moment (IDM) also called homogeneity IDM=N∑i,j=1M(i,j)1+(i−j)2
- A sum average indicator (SAv) SAv=N∑i,j=1M(i,j)×(i+j)
- A sum variance indicator (SVa) SVa=N∑i,j=1M(i,j)×(i+j−SAv)2
- A sum entropy indicator (SEn) SEn=−2N∑k=2Mx+y(k)×log(Mx+y(k)) where Mx+y(k)=∑i+j=kM(i,j)
- An entropy indicator (Ent) Ent=−N∑i,j=1M(i,j)×log(M(i,j))
- A difference variance indicator (DVa) DVa=variance(Mx−y) where Mx−y(k)=∑|i−j|=kM(i,j)
- A difference entropy indicator (DEn) DEn=−N−1∑k=0Mx−y(k)×log(Mx−y(k))
- Two information measurements of correlation (IC1 and IC2) IC1=HXY−HXY1max(HX,HY) where IC2=√1−e−2×|HXY2−HXY|
- where:
μ=N∑i,j=1i×M(i,j) and σ2=N∑i,j=1M(i,j)×(i−μ)2
- where HX and HY are entropies of Mx and My such as
Mx(i)=N∑j=1M(i,j) and My(j)=N∑i=1M(i,j)
and
HXY=−N∑i,j=1M(i,j)×log(M(i,j))
HXY1=−N∑i,j=1M(i,j)×log(Mx(i)×My(j))
HXY2=−N∑i,j=1Mx(i)×My(j)×log(Mx(i)×My(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 );
Class Syntax
Parameters
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 ) ;
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 ) ;