This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Functions | |
| QImage * | pointillismEffect (QString filename, ManipulationOptions *options) |
|
||||||||||||
|
Definition at line 109 of file pointillism.cpp. References blackWhiteEffect(), computeLocalGrayVal(), drawDotAt(), editedImage, and pickRandomPixelWithinBlock(). Referenced by EditingInterface::applyEffect(). 00110 {
00111 //intialize seed using current time
00112 srand( unsigned(time(NULL)) );
00113
00114 //load original image and convert to grayscale
00115 QImage* originalImage = blackWhiteEffect( filename, NULL );
00116
00117 //construct edited image
00118 QImage* editedImage = new QImage( originalImage->width(),
00119 originalImage->height(),
00120 originalImage->depth() );
00121
00122 //fill with white since we'll be drawing black/color dots on top
00123 editedImage->fill( qRgb(255,255,255) );
00124
00125 //break image into BLOCK_SIZE x BLOCK_SIZE blocks. iterate over
00126 //each block and pick a random pixel within. Local
00127 //average gray value in edited image is > originalImage + thresh
00128 //then draw a dot at pixel. continue doing this for each block
00129 //and repeat until ???
00130 const int BLOCK_SIZE = 8;
00131
00132 //compute image size in blocks
00133 int blocksWide = editedImage->width() / BLOCK_SIZE;
00134 if(blocksWide*BLOCK_SIZE < editedImage->width())
00135 { blocksWide++; }
00136
00137 int blocksTall = editedImage->height() / BLOCK_SIZE;
00138 if(blocksTall*BLOCK_SIZE < editedImage->height())
00139 { blocksTall++; }
00140
00141 //iterate over image say 100 times, we'll need to fix this outer loop to be smarter?
00142 int bx,by,x,y;
00143 for(int i=0; i<10; i++)
00144 {
00145 //iterate over all blocks
00146 for(bx=0; bx<blocksWide; bx++)
00147 {
00148 for(by=0; by<blocksTall; by++)
00149 {
00150 //pick random pixel within block
00151 pickRandomPixelWithinBlock( editedImage->width(),
00152 editedImage->height(),
00153 bx, by,
00154 BLOCK_SIZE,
00155 x, y );
00156
00157 double curGrayVal = computeLocalGrayVal( editedImage, x, y );
00158 double goalGrayVal = computeLocalGrayVal( originalImage, x, y );
00159
00160 //too bright -> draw dot
00161 if( curGrayVal > goalGrayVal )
00162 { drawDotAt( editedImage, x, y, 5 ); }
00163 }
00164 }
00165 }
00166
00167 //free grayscale form of original image
00168 delete originalImage;
00169 originalImage = NULL;
00170
00171 //return pointer to edited image
00172 return editedImage;
00173 }
|
1.3.9.1