brightness/contrast/gamma
This commit is contained in:
parent
3946c846ab
commit
d833cd8995
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user