void Gettexturefun(CImage * image,double *xf)
{
if (image->IsNull()) return;
int i,j;
int nWidth = image->GetWidth();
int nHeight = image->GetHeight();
int k;
k=0;
int **source = new int *[nWidth*2];
for (i = 0;i<nWidth*2;i++)
source[i] = new int [nHeight*2]; for (i = 0;i<nWidth*2;i++)
for ( j =0;j<nHeight*2;j++)
{
source[i][j]= 0;
}
double a[101][101];
for (i=0;i<101;i++)
for (j = 0;j<101;j++)
{ a[i][j] = 0;
}
for (i = 1; i< nWidth-1; i++){
for (j = 1; j < nHeight-1; j++){
int rr = 0, gg = 0, bb = 0; COLORREF clr = image->GetPixel( i, j);
rr=GetRValue(clr);
gg=GetGValue(clr);
bb= GetBValue(clr); rr = (int)(rr);
gg = (int)(gg);
bb = (int)(bb);
source[i][j] = int(0.3*rr+0.59*gg+0.11*bb); // image->SetPixel(i-1,j-1,RGB(rr,gg,bb)); }
}
for (i=0;i<50;i++)
for (j=0;j<50;j++)
{ if (i==j)
{a[i][j] = PXY(i,j,source,nWidth,nHeight);}
} for (i=1;i<50;i++)
for(j=1;j<50;j++)
{
if (i==j)
{ xf[k]= a[i][j]-a[0][0];
k=k+1; }
} for (i = 0;i<nWidth*2;i++)
delete []source[i];
delete []source;
}
{
if (image->IsNull()) return;
int i,j;
int nWidth = image->GetWidth();
int nHeight = image->GetHeight();
int k;
k=0;
int **source = new int *[nWidth*2];
for (i = 0;i<nWidth*2;i++)
source[i] = new int [nHeight*2]; for (i = 0;i<nWidth*2;i++)
for ( j =0;j<nHeight*2;j++)
{
source[i][j]= 0;
}
double a[101][101];
for (i=0;i<101;i++)
for (j = 0;j<101;j++)
{ a[i][j] = 0;
}
for (i = 1; i< nWidth-1; i++){
for (j = 1; j < nHeight-1; j++){
int rr = 0, gg = 0, bb = 0; COLORREF clr = image->GetPixel( i, j);
rr=GetRValue(clr);
gg=GetGValue(clr);
bb= GetBValue(clr); rr = (int)(rr);
gg = (int)(gg);
bb = (int)(bb);
source[i][j] = int(0.3*rr+0.59*gg+0.11*bb); // image->SetPixel(i-1,j-1,RGB(rr,gg,bb)); }
}
for (i=0;i<50;i++)
for (j=0;j<50;j++)
{ if (i==j)
{a[i][j] = PXY(i,j,source,nWidth,nHeight);}
} for (i=1;i<50;i++)
for(j=1;j<50;j++)
{
if (i==j)
{ xf[k]= a[i][j]-a[0][0];
k=k+1; }
} for (i = 0;i<nWidth*2;i++)
delete []source[i];
delete []source;
}
int nWidth = image->GetWidth();
int nHeight = image->GetHeight();
这里就是通过实例调用方法source[i][j] = int(0.3*rr+0.59*gg+0.11*bb);
象这里注意一下精准度。