diff --git a/src/core/transformations/correction.cpp b/src/core/transformations/correction.cpp index b78c7a1..12545fe 100644 --- a/src/core/transformations/correction.cpp +++ b/src/core/transformations/correction.cpp @@ -21,7 +21,34 @@ PNM* Correction::transform() PNM* newImage = new PNM(width, height, image->format()); - qDebug() << Q_FUNC_INFO << "Not implemented yet!"; + for (int y = 0; y < height; ++y) + { + for (int x = 0; x < width; ++x) + { + QRgb pixel = image->pixel(x, y); + int red = qRed(pixel); + int green = qGreen(pixel); + int blue = qBlue(pixel); + + red += shift; + green += shift; + blue += shift; + + red *= factor; + green *= factor; + blue *= factor; + + red = pow(red / 255.0, gamma) * 255; + green = pow(green / 255.0, gamma) * 255; + blue = pow(blue / 255.0, gamma) * 255; + + red = qBound(0, red, 255); + green = qBound(0, green, 255); + blue = qBound(0, blue, 255); + + newImage->setPixel(x, y, qRgb(red, green, blue)); + } + } return newImage; }