upload correction task

This commit is contained in:
BohdanBakhlul 2021-05-08 12:19:57 +02:00
parent 5da7ec6ba0
commit 9dc5eeed6b

View File

@ -21,7 +21,30 @@ PNM* Correction::transform()
PNM* newImage = new PNM(width, height, image->format()); 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; x<width; x++)
for (int y=0; y<height; y++)
{
QRgb pixel = image->pixel(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; return newImage;
} }