int maxNum(int *n)
{
int Maximum = n[0];
for(int i = 1; i <= 8; i++)
{
if( Maximum < n[i] )
Maximum = abs(n[i]);
}
return Maximum;
}
void DibHomoginityDetect(CDib& dib)
{
register int i,j,x[8];
int w = dib.GetWidth();
int h= dib.GetHeight();
CDib cpy =dib;
BYTE** ptr1 = dib.GetPtr();
BYTE** ptr2 = cpy.GetPtr();
for(j = 1;j<h-1;j++)
{
for(i=1;i<w-1;i++)
{
x[1]= (ptr2[j][i]-ptr2[j-1][i-1]);
x[2] =(ptr2[j][i]-ptr2[j-1][i]);
x[3] =(ptr2[j][i]-ptr2[j-1][i+1]);
x[4] =(ptr2[j][i]-ptr2[j][i-1]);
x[5] =(ptr2[j][i]-ptr2[j][i+1]);
x[6] =(ptr2[j][i]-ptr2[j+1][i-1]);
x[7] =(ptr2[j][i]-ptr2[j+1][i]);
x[8] =ptr2[j][i]-ptr2[j+1][i+1];
//assign the central pixel of window to image central pixel
ptr1[j][i] = (BYTE)maxNum(x);
}
}
}
what is wrong with this program.. as i understand it should work but i am getting exception error …
Anyone can hellp me that where did i make mistake .. .. thanks
Kind of hard to tell from the code, but I guess your for-loop should really be:
Arrays in C++ are indexed from zero, not one.