69 int weights[3][3] = { {1,2,1}, {2,4,2}, {1,2,1} };
74 for(yp = QMAX( y-1, 0); yp < QMIN( image->height()-1, y+1 ); yp++)
76 uchar* scanLine = image->scanLine(yp);
78 for(xp = QMAX( x-1, 0); xp< QMIN( image->width()-1, x+1 ); xp++)
89 sum+= (weights[weightX][weightY] * qGray( *((QRgb*)scanLine+xp) ) );
90 divisorSum+= weights[weightX][weightY];
95 return sum/divisorSum;
112 srand(
unsigned(time(NULL)) );
118 QImage*
editedImage =
new QImage( originalImage->width(),
119 originalImage->height(),
120 originalImage->depth() );
130 const int BLOCK_SIZE = 8;
133 int blocksWide =
editedImage->width() / BLOCK_SIZE;
134 if(blocksWide*BLOCK_SIZE < editedImage->
width())
137 int blocksTall =
editedImage->height() / BLOCK_SIZE;
138 if(blocksTall*BLOCK_SIZE < editedImage->
height())
143 for(
int i=0; i<10; i++)
146 for(bx=0; bx<blocksWide; bx++)
148 for(by=0; by<blocksTall; by++)
161 if( curGrayVal > goalGrayVal )
168 delete originalImage;
169 originalImage = NULL;
void pickRandomPixelWithinBlock(int width, int height, int blockX, int blockY, int BLOCK_SIZE, int &x, int &y)