How to calculate the value of the glcm feature?
My code just arrived at matrix normalization, how to calculate the value of glcm features such as entropy, energy, contrast, correlation, and homogeneity. Here is the code
private void Classification() {
Mat gl = Mat.zeros(256, 256, CvType.CV_64F);
Mat glt = gl.clone();
//Create GLCM d= 1 , angle = 0
for (int y = 0; y < finalResult.rows(); y++) {
for (int x = 0; x < finalResult.cols()-1; x++) {
int i = (int) finalResult.get(y, x)[0];
int j = (int) finalResult.get(y, x + 1)[0];
double[] count = gl.get(i, j);
count[0]++;
gl.put(i, j, count);
}
}
//GLCM Transpose
Core.transpose(gl, glt);
//Symmetric Matrix
Core.add(gl, glt, gl);
//Matrix Normalization
Scalar sum = Core.sumElems(gl);
Core.divide(gl, sum, gl);