diff --git a/src/core/transformations/correction.cpp b/src/core/transformations/correction.cpp index b78c7a1..62343a6 100644 --- a/src/core/transformations/correction.cpp +++ b/src/core/transformations/correction.cpp @@ -21,7 +21,30 @@ PNM* Correction::transform() PNM* newImage = new PNM(width, height, image->format()); - qDebug() << Q_FUNC_INFO << "Not implemented yet!"; + for (int i=0; i<256; ++i) { + + int newColor = pow(i, gamma); + newColor = newColor * factor; + newColor = newColor + shift; + + if (newColor > 255) newColor = 255; + else if (newColor < 0) newColor = 0; + + LUT[i] = newColor; + } + + for (int x=0; xpixel(x,y); + + int red = LUT[qRed(pixel)]; + int green = LUT[qGreen(pixel)]; + int blue = LUT[qBlue(pixel)]; + + newImage->setPixel(x,y, QColor(red,green,blue).rgb()); + } return newImage; } +