for(Y=0; Y<=(originalImage.rows-1); Y++) {
for(X=0; X<=(originalImage.cols-1); X++) {
SUM = 0;
/* image boundaries */
if(Y==0 Y==1 Y==originalImage.rows-2 Y==originalImage.rows-1)
SUM = 0;
else if(X==0 X==1 X==originalImage.cols-2 X==originalImage.cols-1)
SUM = 0;
/* Convolution starts here */
else {
for(I=-2; I<=2; I++) {
for(J=-2; J<=2; J++) {
SUM = SUM + (int)( (*(originalImage.data + X + I +
(Y + J)*originalImage.cols)) * MASK[I+2][J+2]);
}
}
}
if(SUM>255) SUM=255;
if(SUM<0) SUM=0;
*(edgeImage.data + X + Y*originalImage.cols) = 255 - (unsigned char)(SUM);
fwrite((edgeImage.data + X + Y*originalImage.cols),sizeof(char),1,bmpOutput);
}
}
No comments:
Post a Comment