[TASK] Migrate histogramm adaption over to YUV.
This commit is contained in:
parent
b762a3a076
commit
6ead23f875
|
@ -229,8 +229,8 @@ void ImageViewer::analyzeImage() {
|
||||||
* @brief ImageViewer::adjustBrightness
|
* @brief ImageViewer::adjustBrightness
|
||||||
*/
|
*/
|
||||||
void ImageViewer::adjustBrightness(int b) {
|
void ImageViewer::adjustBrightness(int b) {
|
||||||
int h, s, old_l;
|
//int h, s, old_l;
|
||||||
int new_l = 0;
|
//int new_l = 0;
|
||||||
int delta = b - 255;
|
int delta = b - 255;
|
||||||
for(int x=0; x<working_copy->getImage()->width(); x++) {
|
for(int x=0; x<working_copy->getImage()->width(); x++) {
|
||||||
for(int y=0; y<working_copy->getImage()->height(); y++) {
|
for(int y=0; y<working_copy->getImage()->height(); y++) {
|
||||||
|
@ -249,8 +249,8 @@ void ImageViewer::adjustBrightness(int b) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateImageDisplay();
|
updateImageDisplay();
|
||||||
logFile << "Brightness adjusted to: " << old_l << " + " << delta << " -> (" << h << ", " << s << ", " << new_l << ")" << std::endl;
|
//logFile << "Brightness adjusted to: " << old_l << " + " << delta << " -> (" << h << ", " << s << ", " << new_l << ")" << std::endl;
|
||||||
renewLogging();
|
//renewLogging();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -349,17 +349,19 @@ void ImageViewer::robustAutomaticContrastAdaption(int c_param) {
|
||||||
void ImageViewer::linearHistogrammAdaption(void) {
|
void ImageViewer::linearHistogrammAdaption(void) {
|
||||||
logFile << "Doing linear histogramm adaption ..." << std::endl;
|
logFile << "Doing linear histogramm adaption ..." << std::endl;
|
||||||
renewLogging();
|
renewLogging();
|
||||||
int h, s, l;
|
//int h, s, l;
|
||||||
int* ach = original->getAbsoluteCumulativeIntensityHistogramm();
|
int* ach = original->getAbsoluteCumulativeIntensityHistogramm();
|
||||||
int pixels = working_copy->getImage()->width()*working_copy->getImage()->height();
|
int pixels = working_copy->getImage()->width()*working_copy->getImage()->height();
|
||||||
for(int x=0; x<working_copy->getImage()->width(); x++) {
|
for(int x=0; x<working_copy->getImage()->width(); x++) {
|
||||||
for(int y=0; y<working_copy->getImage()->height(); y++) {
|
for(int y=0; y<working_copy->getImage()->height(); y++) {
|
||||||
QColor color = QColor::fromRgb(original->getImage()->pixel(x, y));
|
QColor color = QColor::fromRgb(original->getImage()->pixel(x, y));
|
||||||
color.getHsl(&h, &s, &l);
|
//color.getHsl(&h, &s, &l);
|
||||||
|
//l = (int) qFloor(ach[l] * (255.0/pixels));
|
||||||
l = (int) qFloor(ach[l] * (255.0/pixels));
|
//color.setHsl(h, s, l);
|
||||||
|
struct yuv yuv = LazyImage::RGBToYUV(color.rgb());
|
||||||
color.setHsl(h, s, l);
|
int l = qRound(yuv.y * 255.0);
|
||||||
|
yuv.y = qFloor(ach[l] * (255.0/pixels)) / 255.0;
|
||||||
|
color = LazyImage::YUVToRGB(yuv);
|
||||||
working_copy->getImage()->setPixel(x, y, color.rgb());
|
working_copy->getImage()->setPixel(x, y, color.rgb());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -426,13 +428,17 @@ void ImageViewer::partialLinearHistogrammAdaption() {
|
||||||
renewLogging();
|
renewLogging();
|
||||||
|
|
||||||
// Apply the brightness map
|
// Apply the brightness map
|
||||||
int h, s, l;
|
//int h, s, l;
|
||||||
for(int x=0; x<working_copy->getImage()->width(); x++) {
|
for(int x=0; x<working_copy->getImage()->width(); x++) {
|
||||||
for(int y=0; y<working_copy->getImage()->height(); y++) {
|
for(int y=0; y<working_copy->getImage()->height(); y++) {
|
||||||
QColor color = QColor::fromRgb(original->getImage()->pixel(x, y));
|
QColor color = QColor::fromRgb(original->getImage()->pixel(x, y));
|
||||||
color.getHsl(&h, &s, &l);
|
//color.getHsl(&h, &s, &l);
|
||||||
l = brightness_map[l];
|
//l = brightness_map[l];
|
||||||
color.setHsl(h, s, l);
|
//color.setHsl(h, s, l);
|
||||||
|
struct yuv yuv = LazyImage::RGBToYUV(color.rgb());
|
||||||
|
int l = qRound(yuv.y * 255.0);
|
||||||
|
yuv.y = qFloor(brightness_map[l]) / 255.0;
|
||||||
|
color = LazyImage::YUVToRGB(yuv);
|
||||||
working_copy->getImage()->setPixel(x, y, color.rgb());
|
working_copy->getImage()->setPixel(x, y, color.rgb());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -482,13 +488,17 @@ void ImageViewer::succeedingHistogrammAdaption() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply the map for each pixel.
|
// Apply the map for each pixel.
|
||||||
int h, s, l;
|
//int h, s, l;
|
||||||
for(int x=0; x<working_copy->getImage()->width(); x++) {
|
for(int x=0; x<working_copy->getImage()->width(); x++) {
|
||||||
for(int y=0; y<working_copy->getImage()->height(); y++) {
|
for(int y=0; y<working_copy->getImage()->height(); y++) {
|
||||||
QColor color = QColor::fromRgb(original->getImage()->pixel(x, y));
|
QColor color = QColor::fromRgb(original->getImage()->pixel(x, y));
|
||||||
color.getHsl(&h, &s, &l);
|
//color.getHsl(&h, &s, &l);
|
||||||
l = histogramm_map[l];
|
//l = histogramm_map[l];
|
||||||
color.setHsl(h, s, l);
|
//color.setHsl(h, s, l);
|
||||||
|
struct yuv yuv = LazyImage::RGBToYUV(color.rgb());
|
||||||
|
int l = qRound(yuv.y * 255.0);
|
||||||
|
yuv.y = qFloor(histogramm_map[l]) / 255.0;
|
||||||
|
color = LazyImage::YUVToRGB(yuv);
|
||||||
working_copy->getImage()->setPixel(x, y, color.rgb());
|
working_copy->getImage()->setPixel(x, y, color.rgb());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue