From 9dc5eeed6b5a82fea409beb442c49f88f89f2488 Mon Sep 17 00:00:00 2001 From: BohdanBakhlul Date: Sat, 8 May 2021 12:19:57 +0200 Subject: [PATCH] upload correction task --- src/core/transformations/correction.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) 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; } +