/**************************************************************************** * Func: difference * * * * Desc: finds edges in an image window using the difference operator * * * * Param: window - 3x3 window of source image |0 1 2| * * |3 4 5| * * |6 7 8| * * * * Returns: the maximum value of the differences across the center pixel * ****************************************************************************/ int difference(unsigned char *window) { int max; /* current maximum difference */ int diff; /* current difference */ diff = abs(window[0] - window[8]); /* upper left - lower right */ max = diff; diff = abs(window[1] - window[7]); /* upper - lower */ if(diff > max) max = diff; diff = abs(window[2] - window[6]); /* upper right - lower left */ if(diff > max) max = diff; diff = abs(window[5] - window[3]); /* left - right */ if(diff > max) max = diff; return max; }