Home > Software engineering >  Written in MFC program collapse, sometimes tip may be damaged, heap for help
Written in MFC program collapse, sometimes tip may be damaged, heap for help

Time:09-25

 # include "stdafx. H" 
# include
# include
# include "GLCM. H"
# include
# include
# include
# include
Using the namespace CV;
using namespace std;
Void the_GLCM: : calGLCM (int * data, int scale, int GRAY_CLASS, int, short, int direction, double * index)
{
Int width, height;
Width=scale;
Height=scale;
Int * indata=https://bbs.csdn.net/topics/new int width/height *];
Double * indata1=new double width/height *];
Int * GLCM=new int [GRAY_CLASS * GRAY_CLASS];//gray level co-occurrence matrix
Double * glcm1=new double [GRAY_CLASS * GRAY_CLASS];//after normalization of gray level co-occurrence matrix
//int * imaged=new int (width * height);//read the data

////read in grey value and stored in the array
//* * * * * * * * * * * * * * * * this is a compressed grayscale part, specific for compressed into GRAY_CLASS
for(int i=0; i{
for(int j=0; j{
Double sf=(GRAY_CLASS * (data/width * I + j)/(255));
Indata [I * width + j]=sf;
}
}
for(int i=0; i{
for(int j=0; j{
GLCM GRAY_CLASS + j] [I *=0;
Glcm1 GRAY_CLASS + j] [I *=0;
}
}
Int d=short;
//start the next step of gray level co-occurrence matrix computation
Int w, k, l;
If (direction==ANGLE_1)//build direction 0 degrees to symbiotic matrix
{
for(int i=0; i{
for(int j=0; j{
L=indata [I * width + j];//sure I elements in P (I, j)
If (j + DISTANCE>=0 & amp; & J + DISTANCE{
K=indata [I * width + j + short];//sure j elements of P (I, j)
GLCM [l] * GRAY_CLASS + k + +;//to the right
}
//if (j - DISTANCE>=0 & amp; & J - DISTANCE//{
//k=indata [I * width + j - short];//sure j elements of P (I, j)
//GLCM [l * GRAY_CLASS + k] + +;//the left
*//*}
}
}
}
Else if (direction==ANGLE_2)//build direction of 45 degrees to the symbiotic matrix
{
for(int i=0; i{
for(int j=0; j{
L=indata [I * width + j];//sure I elements in P (I, j)
If (I - DISTANCE>=0 & amp; & I - DISTANCE=0 & amp; & J + DISTANCE{
K=indata [(I - short) * width + j + short];//sure j elements of P (I, j)
GLCM [l] * GRAY_CLASS + k + +;
}
//if (I + DISTANCE>=0 & amp; & I + DISTANCE=0 & amp; & J - DISTANCE//{
//k=indata [+ short (I) * width + j - short];//sure j elements of P (I, j)
//GLCM [l * GRAY_CLASS + k] + +;
*//*}
}
}
}

Else if (direction==ANGLE_3)//direction for 90 degrees co-occurrence matrix
{
for(int i=0; i{
for(int j=0; j{
L=indata [I * width + j];//sure I elements in P (I, j)
//if (I + DISTANCE>=0 & amp; & I + DISTANCE//{
//k=indata [+ short (I) * width + j];//sure j elements of P (I, j)
//GLCM [l * GRAY_CLASS + k] + +;
//}
If (I - DISTANCE>=0 & amp; & I - DISTANCE{
K=indata [(I - short) * width + j];//sure j elements of P (I, j)
GLCM [l] * GRAY_CLASS + k + +;
}
}
}
}
Else if (direction==ANGLE_4)//direction for 135 degrees co-occurrence matrix
{
for(int i=0; i{
for(int j=0; j{
L=indata [I * width + j];//sure I elements in P (I, j)
//if (j + DISTANCE>=0 & amp; & I + DISTANCE>=0 & amp; & J + DISTANCE//{
//k=indata [+ short (I) * width + j + short];//sure j elements of P (I, j)
//GLCM [l * GRAY_CLASS + k] + +;
//}
If (j - DISTANCE>=0 & amp; & I - DISTANCE>=0 & amp; & J - DISTANCE{
K=indata [(I - short) * width + j - short];//sure j elements of P (I, j)
GLCM [l] * GRAY_CLASS + k + +;
}
}
}
}
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * the test * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Double Meani Meanj, Stdi Stdj, Entropy, Homogeneity, Contrast, Dissimilarity, ASM, the Correlation;//GLCM eight characteristic value
Meani=0;
Meanj=0;
double sum=0;//used for normalization
For (int p=0; p{
For (int q=0; Q{
Sum=sum + GLCM [p] * GRAY_CLASS + q;//calculate the GLCM is worth the sum of
}
}
For (int i1=0; I1 & lt; GRAY_CLASS; I1 + +)
{
For (int j1=0; J1 & lt; GRAY_CLASS; J1 + +)
{
Glcm1 [i1 * GRAY_CLASS + j1]=GLCM [i1 * GRAY_CLASS + j1]/sum;//normalized calculation
}
}

for(int i=0; i{
for(int j=0; j{
Meani +=glcm1 GRAY_CLASS + j] [I * * I;//solving scheme of value
}
}
for(int i=0; i{
for(int j=0; j{
Meanj +=glcm1 GRAY_CLASS + j] [I * * j;
}
}

Double variancei=0;//variance I
Double variancej=0;//variance j
Entropy=0;
Homogeneity=0;
Contrast=0;
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related