redEye.h File Reference

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

Go to the source code of this file.

Functions

QImage * removeRedeyeRegions (QString filename, QPoint topLeftExtreme, QPoint bottomRightExtreme, StatusWidget *status)


Function Documentation

QImage* removeRedeyeRegions ( QString  filename,
QPoint  topLeftExtreme,
QPoint  bottomRightExtreme,
StatusWidget status 
)

Definition at line 206 of file redEye.cpp.

References desaturateBlobs(), desaturateEntireImage(), editedImage, findBestTwoBlobs(), findBlobs(), findRegionOfInterest(), id1, newProgress, rawImage, StatusWidget::setStatus(), StatusWidget::showProgressBar(), sortBlobsByDecreasingSize(), status, topLeft, and updateIncrement.

Referenced by EditingInterface::removeRedeye().

00209 {
00210   //store handle to status widget
00211   status = statusWidget;
00212   
00213   //load original image
00214   rawImage = QImage( filename );
00215   
00216   //sanity check: unable to load image
00217   if(rawImage.isNull()) { return NULL; }
00218 
00219   //convert to 32-bit depth if necessary
00220   if( rawImage.depth() < 32 ) { rawImage = rawImage.convertDepth( 32, Qt::AutoColor ); }
00221    
00222   //sanity check: make sure topLeftExtreme and bottomRightExtreme are within image boundary
00223   topLeftExtreme.setX( QMAX( topLeftExtreme.x(), 0 ) );
00224   topLeftExtreme.setY( QMAX( topLeftExtreme.y(), 0 ) );
00225   bottomRightExtreme.setX( QMIN( bottomRightExtreme.x(), rawImage.width()-1 ) );
00226   bottomRightExtreme.setY( QMIN( bottomRightExtreme.y(), rawImage.height()-1 ) );
00227 
00228   //setup progress bar
00229   QString statusMessage = qApp->translate( "removeRedeyeRegions", "Removing Red-Eye:" );
00230   status->showProgressBar( statusMessage, 100 );
00231   qApp->processEvents();  
00232   
00233   //update progress bar for every 1% of completion
00234   updateIncrement = (int) ( 0.01 * 
00235                             ( bottomRightExtreme.x() - topLeftExtreme.x() + 1 ) *
00236                             ( bottomRightExtreme.y() - topLeftExtreme.y() + 1 ) );
00237   newProgress = 0;   
00238 
00239   //find region of interest: constrain search box to boundary that actually contains red enough pixels
00240   findRegionOfInterest(topLeftExtreme, bottomRightExtreme);
00241 
00242   //if no pixels were found then immediately return a NULL pointer signaling no change
00243   if(topLeft.x() == -1) 
00244   { 
00245     //hide progress bar
00246     status->setStatus( "" );
00247     qApp->processEvents();
00248 
00249     return NULL; 
00250   }
00251 
00252   //load an editing image
00253   //two images mus be loaded becuase pixel values are replaced
00254   //using a compbination of niehgbors and their own in order
00255   //to avoid sharp lines at the edge of the saturated region
00256   editedImage = new QImage( filename );
00257   
00258   //sanity check: unable to allocated edited image
00259   if( editedImage == NULL) 
00260   { 
00261     //hide progress bar
00262     status->setStatus( "" );
00263     qApp->processEvents();
00264 
00265     return NULL; 
00266   }
00267 
00268   //convert to 32-bit depth if necessary
00269   if( editedImage->depth() < 32 )
00270   {
00271     QImage* tmp = editedImage;
00272     editedImage = new QImage( tmp->convertDepth( 32, Qt::AutoColor ) );
00273     delete tmp; tmp=NULL;
00274   }
00275   
00276   findBlobs();
00277   sortBlobsByDecreasingSize();
00278   findBestTwoBlobs();
00279 
00280   //if we found two good blobs then desaturate those only
00281   if(id1 != -1)
00282   {
00283     desaturateBlobs();
00284   }
00285   //else desaturate all pixels above thresh within selection area
00286   else
00287   {
00288     desaturateEntireImage(topLeftExtreme, bottomRightExtreme);
00289   }
00290 
00291   //remove status bar
00292   status->setStatus( "" );
00293   qApp->processEvents();
00294 
00295   //return pointer to edited image
00296   return editedImage;      
00297 }


Generated on Sun Aug 23 02:34:31 2009 for AlbumShaper by  doxygen 1.5.9