larrifari
September 18th, 2009, 07:58 AM
I am trying to keep it very simple, I cant see anything wrong with my logic, could anybody help point me to the right direction?!!
{ int Shorizontal[] = {-1, 0, 1, -2, 0, 2, -1, 0, 1};
int Svertical[] = {1, 2, 1, 0, 0, 0, -1, -2, -1};
for (int x = 0; x < image.dimx(); x++)
for (int y = 0; y < image.dimy(); y++)
for (int c = 0; c < 3; c++) // loop through colour channels
{ int counter = 0;
float tempH = 0;
float tempV = 0;
for (int a = -1; a <= 1; a++)
for (int b = -1; b <= 1; b++)
if (x + a >= 0 && x + a <= image.dimx() && y + b >= 0 && y + b <= image.dimy())
{ tempH += image(x + a,y + b,0, c) * Shorizontal[counter];
tempV += image(x + a,y + b,0, c) * Svertical[counter];
counter++;
}
image(x,y,0,c) = sqrt(pow(tempH,2) + pow(tempV,2));
}
}
{ int Shorizontal[] = {-1, 0, 1, -2, 0, 2, -1, 0, 1};
int Svertical[] = {1, 2, 1, 0, 0, 0, -1, -2, -1};
for (int x = 0; x < image.dimx(); x++)
for (int y = 0; y < image.dimy(); y++)
for (int c = 0; c < 3; c++) // loop through colour channels
{ int counter = 0;
float tempH = 0;
float tempV = 0;
for (int a = -1; a <= 1; a++)
for (int b = -1; b <= 1; b++)
if (x + a >= 0 && x + a <= image.dimx() && y + b >= 0 && y + b <= image.dimy())
{ tempH += image(x + a,y + b,0, c) * Shorizontal[counter];
tempV += image(x + a,y + b,0, c) * Svertical[counter];
counter++;
}
image(x,y,0,c) = sqrt(pow(tempH,2) + pow(tempV,2));
}
}