15 #define MIN(x,y) ((x) < (y) ? (x) : (y)) 16 #define MAX(x,y) ((x) < (y) ? (x) : (y)) 21 #include "../tools/imageTools.h" 96 QPoint offset, QSize fullImageRes,
100 QImage blurredImage = image.copy();
105 QRgb *origRgb, *blurredRgb, *edgeRgb;
107 uchar *blurredScanline;
108 uchar *edgesScanline = NULL;
110 for(y=0; y<image.height(); y++)
112 origScanline = image.scanLine(y);
113 blurredScanline = blurredImage.scanLine(y);
114 if( edgeImage != NULL )
116 int edgeY = ((edgeImage->height()-1) * (y+offset.y())) / (fullImageRes.height()-1);
117 edgesScanline = edgeImage->scanLine(edgeY);
120 for(x=0; x<image.width(); x++)
123 origRgb = ((QRgb*)origScanline+x);
124 double r1 = ((double)qRed(*origRgb) )/255.0;
125 double g1 = ((double)qGreen(*origRgb) )/255.0;
126 double b1 = ((double)qBlue(*origRgb) )/255.0;
128 blurredRgb = ((QRgb*)blurredScanline+x);
129 double r2 = ((double)qRed(*blurredRgb) )/255.0;
130 double g2 = ((double)qGreen(*blurredRgb) )/255.0;
131 double b2 = ((double)qBlue(*blurredRgb) )/255.0;
135 if( edgeImage == NULL)
139 int edgeX = ((edgeImage->width()-1) * (x+offset.x())) / (fullImageRes.width()-1);
140 edgeRgb = ((QRgb*)edgesScanline+edgeX);
142 alpha = ((float) qRed( *edgeRgb )) / 255.0f;
146 alpha = 1.0f - alpha;
157 v1 = (alpha *
MIN(
MAX(2*v1 - v2, 0), 1.0 )) + (1-alpha)*v1;
161 int rp = (int)
MIN(
MAX((r1*255), 0), 255 );
162 int gp = (int)
MIN(
MAX((g1*255), 0), 255 );
163 int bp = (int)
MIN(
MAX((b1*255), 0), 255 );
166 *origRgb = qRgb(rp,gp,bp);
void blurImage(QImage &image, float sigma)
void sharpenImage(QImage &image, float sigma, QPoint offset, QSize fullImageRes, QImage *edgeImage, bool blurEdges)