Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

redEye.h File Reference

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

Included by dependency graph

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 22 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().

00025 {
00026   //store handle to status widget
00027   status = statusWidget;
00028   
00029   //load original image
00030   rawImage = QImage( filename );
00031   
00032   //sanity check: unable to load image
00033   if(rawImage.isNull()) { return NULL; }
00034 
00035   //sanity check: make sure topLeftExtreme and bottomRightExtreme are within image boundary
00036   topLeftExtreme.setX( QMAX( topLeftExtreme.x(), 0 ) );
00037   topLeftExtreme.setY( QMAX( topLeftExtreme.y(), 0 ) );
00038   bottomRightExtreme.setX( QMIN( bottomRightExtreme.x(), rawImage.width()-1 ) );
00039   bottomRightExtreme.setY( QMIN( bottomRightExtreme.y(), rawImage.height()-1 ) );
00040 
00041   //setup progress bar
00042   QString statusMessage = qApp->translate( "removeRedeyeRegions", "Removing Red-Eye:" );
00043   status->showProgressBar( statusMessage, 100 );
00044   qApp->processEvents();  
00045   
00046   //update progress bar for every 1% of completion
00047   updateIncrement = (int) ( 0.01 * 
00048                             ( bottomRightExtreme.x() - topLeftExtreme.x() + 1 ) *
00049                             ( bottomRightExtreme.y() - topLeftExtreme.y() + 1 ) );
00050   newProgress = 0;   
00051 
00052   //find region of interest: constrain search box to boundary that actually contains red enough pixels
00053   findRegionOfInterest(topLeftExtreme, bottomRightExtreme);
00054 
00055   //if no pixels were found then immediately return a NULL pointer signaling no change
00056   if(topLeft.x() == -1) 
00057   { 
00058     //hide progress bar
00059     status->setStatus( "" );
00060     qApp->processEvents();
00061 
00062     return NULL; 
00063   }
00064 
00065   //load an editing image
00066   //two images mus be loaded becuase pixel values are replaced
00067   //using a compbination of niehgbors and their own in order
00068   //to avoid sharp lines at the edge of the saturated region
00069   editedImage = new QImage( filename );
00070   
00071   //sanity check: unable to allocated edited image
00072   if( editedImage == NULL) 
00073   { 
00074     //hide progress bar
00075     status->setStatus( "" );
00076     qApp->processEvents();
00077 
00078     return NULL; 
00079   }
00080 
00081   findBlobs();
00082   sortBlobsByDecreasingSize();
00083   findBestTwoBlobs();
00084 
00085   //if we found two good blobs then desaturate those only
00086   if(id1 != -1)
00087   {
00088     desaturateBlobs();
00089   }
00090   //else desaturate all pixels above thresh within selection area
00091   else
00092   {
00093     desaturateEntireImage(topLeftExtreme, bottomRightExtreme);
00094   }
00095 
00096   //remove status bar
00097   status->setStatus( "" );
00098   qApp->processEvents();
00099 
00100   //return pointer to edited image
00101   return editedImage;      
00102 }


Generated on Sat Apr 2 05:44:34 2005 for AlbumShaper by  doxygen 1.3.9.1