AlbumShaper
1.0a3
|
Go to the source code of this file.
Functions | |
QImage * | removeRedeyeRegions (QString filename, QPoint topLeftExtreme, QPoint bottomRightExtreme, StatusWidget *status) |
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().
{ //store handle to status widget status = statusWidget; //load original image rawImage = QImage( filename ); //sanity check: unable to load image if(rawImage.isNull()) { return NULL; } //convert to 32-bit depth if necessary if( rawImage.depth() < 32 ) { rawImage = rawImage.convertDepth( 32, Qt::AutoColor ); } //sanity check: make sure topLeftExtreme and bottomRightExtreme are within image boundary topLeftExtreme.setX( QMAX( topLeftExtreme.x(), 0 ) ); topLeftExtreme.setY( QMAX( topLeftExtreme.y(), 0 ) ); bottomRightExtreme.setX( QMIN( bottomRightExtreme.x(), rawImage.width()-1 ) ); bottomRightExtreme.setY( QMIN( bottomRightExtreme.y(), rawImage.height()-1 ) ); //setup progress bar QString statusMessage = qApp->translate( "removeRedeyeRegions", "Removing Red-Eye:" ); status->showProgressBar( statusMessage, 100 ); qApp->processEvents(); //update progress bar for every 1% of completion updateIncrement = (int) ( 0.01 * ( bottomRightExtreme.x() - topLeftExtreme.x() + 1 ) * ( bottomRightExtreme.y() - topLeftExtreme.y() + 1 ) ); newProgress = 0; //find region of interest: constrain search box to boundary that actually contains red enough pixels findRegionOfInterest(topLeftExtreme, bottomRightExtreme); //if no pixels were found then immediately return a NULL pointer signaling no change if(topLeft.x() == -1) { //hide progress bar status->setStatus( "" ); qApp->processEvents(); return NULL; } //load an editing image //two images mus be loaded becuase pixel values are replaced //using a compbination of niehgbors and their own in order //to avoid sharp lines at the edge of the saturated region editedImage = new QImage( filename ); //sanity check: unable to allocated edited image if( editedImage == NULL) { //hide progress bar status->setStatus( "" ); qApp->processEvents(); return NULL; } //convert to 32-bit depth if necessary if( editedImage->depth() < 32 ) { QImage* tmp = editedImage; editedImage = new QImage( tmp->convertDepth( 32, Qt::AutoColor ) ); delete tmp; tmp=NULL; } findBlobs(); sortBlobsByDecreasingSize(); findBestTwoBlobs(); //if we found two good blobs then desaturate those only if(id1 != -1) { desaturateBlobs(); } //else desaturate all pixels above thresh within selection area else { desaturateEntireImage(topLeftExtreme, bottomRightExtreme); } //remove status bar status->setStatus( "" ); qApp->processEvents(); //return pointer to edited image return editedImage; }