AlbumShaper 1.0a3
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

◆ removeRedeyeRegions()

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

Definition at line 206 of file redEye.cpp.

209{
210 //store handle to status widget
211 status = statusWidget;
212
213 //load original image
214 rawImage = QImage( filename );
215
216 //sanity check: unable to load image
217 if(rawImage.isNull()) { return NULL; }
218
219 //convert to 32-bit depth if necessary
220 if( rawImage.depth() < 32 ) { rawImage = rawImage.convertDepth( 32, Qt::AutoColor ); }
221
222 //sanity check: make sure topLeftExtreme and bottomRightExtreme are within image boundary
223 topLeftExtreme.setX( QMAX( topLeftExtreme.x(), 0 ) );
224 topLeftExtreme.setY( QMAX( topLeftExtreme.y(), 0 ) );
225 bottomRightExtreme.setX( QMIN( bottomRightExtreme.x(), rawImage.width()-1 ) );
226 bottomRightExtreme.setY( QMIN( bottomRightExtreme.y(), rawImage.height()-1 ) );
227
228 //setup progress bar
229 QString statusMessage = qApp->translate( "removeRedeyeRegions", "Removing Red-Eye:" );
230 status->showProgressBar( statusMessage, 100 );
231 qApp->processEvents();
232
233 //update progress bar for every 1% of completion
234 updateIncrement = (int) ( 0.01 *
235 ( bottomRightExtreme.x() - topLeftExtreme.x() + 1 ) *
236 ( bottomRightExtreme.y() - topLeftExtreme.y() + 1 ) );
237 newProgress = 0;
238
239 //find region of interest: constrain search box to boundary that actually contains red enough pixels
240 findRegionOfInterest(topLeftExtreme, bottomRightExtreme);
241
242 //if no pixels were found then immediately return a NULL pointer signaling no change
243 if(topLeft.x() == -1)
244 {
245 //hide progress bar
246 status->setStatus( "" );
247 qApp->processEvents();
248
249 return NULL;
250 }
251
252 //load an editing image
253 //two images mus be loaded becuase pixel values are replaced
254 //using a compbination of niehgbors and their own in order
255 //to avoid sharp lines at the edge of the saturated region
256 editedImage = new QImage( filename );
257
258 //sanity check: unable to allocated edited image
259 if( editedImage == NULL)
260 {
261 //hide progress bar
262 status->setStatus( "" );
263 qApp->processEvents();
264
265 return NULL;
266 }
267
268 //convert to 32-bit depth if necessary
269 if( editedImage->depth() < 32 )
270 {
271 QImage* tmp = editedImage;
272 editedImage = new QImage( tmp->convertDepth( 32, Qt::AutoColor ) );
273 delete tmp; tmp=NULL;
274 }
275
276 findBlobs();
279
280 //if we found two good blobs then desaturate those only
281 if(id1 != -1)
282 {
284 }
285 //else desaturate all pixels above thresh within selection area
286 else
287 {
288 desaturateEntireImage(topLeftExtreme, bottomRightExtreme);
289 }
290
291 //remove status bar
292 status->setStatus( "" );
293 qApp->processEvents();
294
295 //return pointer to edited image
296 return editedImage;
297}
void setStatus(QString message)
Update message.
void showProgressBar(QString message, int numSteps)
Initializes the progress bar.
void sortBlobsByDecreasingSize()
Definition redEye.cpp:468
void desaturateBlobs()
Definition redEye.cpp:612
void findBestTwoBlobs()
Definition redEye.cpp:506
void findRegionOfInterest(QPoint topLeftExtreme, QPoint bottomRightExtreme)
Definition redEye.cpp:305
void findBlobs()
Definition redEye.cpp:372
void desaturateEntireImage(QPoint topLeftExtreme, QPoint bottomRightExtreme)
Definition redEye.cpp:643
int id1
int updateIncrement
QImage rawImage
QImage * editedImage
StatusWidget * status
QPoint topLeft
int newProgress

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

Referenced by EditingInterface::removeRedeye().