www.pudn.com > OPENBITMAP1.rar > GrayShow.cpp
//////////////////////////////////////////////////////////////////////
// GrayShow.cpp: implementation of the CGrayShow class.
// 灰度共现矩阵算法实现
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "OPENBITMAP.h"
#include "GrayShow.h"
#include "math.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CGrayShow::CGrayShow()
{
PMatrixRD = NULL; //45度方向上的灰度共现矩阵
PMatrixLD = NULL; //135度方向上的灰度共现矩阵
PMatrixV = NULL; //90度方向上的灰度共现矩阵
PMatrixH = NULL; //0度方向上的灰度共现矩阵
ImageArray = NULL; //原始的图像数据数组
m_tOriPixelArray = NULL;//原始位图数据
m_tResPixelArray = NULL;//参考位图数据
m_dib = new CDib();
distance = 5;
FilterWindowWidth = 16;
GrayLayerNum = 8; //初始化设为8个灰度层,可以修改
//这样共现矩阵均为GrayLayerNum×GrayLayerNum
int i;
PMatrixH = new int*[GrayLayerNum];
PMatrixLD= new int*[GrayLayerNum];
PMatrixRD= new int*[GrayLayerNum];
PMatrixV = new int*[GrayLayerNum];
for(i=0; iOpen(FilePathName);
ImageWidth = m_dib->GetWidth();
ImageHeight = m_dib->GetHeight();
BYTE *colorTable;
colorTable = (BYTE *)m_dib->m_pDibBits;
int byteBitCount = m_dib->GetBiBitCount()/8;
m_tOriPixelArray = new RGBQUAD*[ImageHeight];
m_tResPixelArray = new RGBQUAD*[ImageHeight];
ImageArray = new BYTE*[ImageHeight];
for(int l=0 ; l=0; i--)
{
for(j=0; j1e-12)
{
FeatureEntropy -= pdMatrix[i][j]*log(pdMatrix[i][j]);
}
//惯性矩
FeatureInertiaQuadrature += (double)(i-j)*(double)(i-j)*pdMatrix[i][j];
//局部平稳
FeatureLocalCalm += pdMatrix[i][j]/(1+(double)(i-j)*(double)(i-j));
}
}
//计算ux
double ux = 0.0;
double localtotal = 0.0;
for(i=0; i