14 #include <qapplication.h> 18 #include "../tools/imageTools.h" 19 #include "../../gui/statusWidget.h" 21 #define MIN(x,y) ((x) < (y) ? (x) : (y)) 22 #define MAX(x,y) ((x) < (y) ? (x) : (y)) 94 if( editedImage->depth() < 32 )
97 editedImage =
new QImage( tmp->convertDepth( 32, Qt::AutoColor ) );
113 QString statusMessage = qApp->translate(
"enhanceImageContrast",
"Enhancing Contrast:" );
115 qApp->processEvents();
119 const int updateIncrement = (int) ( 0.01 * editedImage->width() * editedImage->height() );
129 for(i=0; i<256; i++) { grayVals[i] = 0; }
132 int numPixels = editedImage->width()*editedImage->height();
137 for( y=0; y<editedImage->height(); y++)
140 scanLine = editedImage->scanLine(y);
141 for( x=0; x<editedImage->width(); x++)
143 rgb = ((QRgb*)scanLine+x);
145 grayVals[(int)grayValue]++;
152 double indexLow, indexHigh;
153 indexLow = -1.0; indexHigh = -1.0;
160 sum >= 0.01*numPixels)
162 indexLow = ((double)i)/255.0;
167 sum >= 0.99*numPixels)
169 indexHigh = ((double)i)/255.0;
174 if(indexHigh > indexLow)
177 for( y=0; y<editedImage->height(); y++)
180 scanLine = editedImage->scanLine(y);
181 for( x=0; x<editedImage->width(); x++)
184 rgb = ((QRgb*)scanLine+x);
185 double r = ((double)qRed(*rgb) )/255.0;
186 double g = ((double)qGreen(*rgb) )/255.0;
187 double b = ((double)qBlue(*rgb) )/255.0;
194 v = (v-indexLow)/(indexHigh-indexLow);
198 int rp = (int)
MIN(
MAX((r*255), 0), 255 );
199 int gp = (int)
MIN(
MAX((g*255), 0), 255 );
200 int bp = (int)
MIN(
MAX((b*255), 0), 255 );
203 *rgb = qRgb(rp,gp,bp);
209 if(newProgress >= updateIncrement)
213 qApp->processEvents();
225 qApp->processEvents();
QImage * enhanceImageContrast(QString filename, StatusWidget *status)