[!!! TASK] Begin implementing partial linear histogramm adaption - broken;
This commit is contained in:
parent
fd24f7bb6c
commit
282fa987ed
@ -371,19 +371,53 @@ void ImageViewer::linearHistogrammAdaption(void) {
|
||||
void ImageViewer::partialLinearHistogrammAdaption() {
|
||||
logFile << "Doing partial linear histogramm adaption ..." << std::endl;
|
||||
renewLogging();
|
||||
|
||||
// TODO
|
||||
|
||||
// Get cumulative histogramm from reference image
|
||||
double* reference_histogramm = histogramm_reference->getRelativeCumulativeIntensityHistogramm();
|
||||
|
||||
// Split [0,255] into n parts (slider)
|
||||
// fetch the values for the n parts, do some math and create the histogramm map
|
||||
int number_parts = partial_adaption_pieces_slider->value();
|
||||
int* parts = (int*) malloc(number_parts*sizeof(int));
|
||||
for(int i=0; i<=number_parts; i++) {
|
||||
parts[i] = qRound((255.0/number_parts)*i);
|
||||
}
|
||||
|
||||
// Create
|
||||
double* histogramm_map = (double*) malloc(256*sizeof(double));
|
||||
for(int i=0; i<=number_parts; i++) {
|
||||
int current_n = parts[i];
|
||||
if(current_n == 0) continue; // First part is always at zero!
|
||||
int last_n = parts[i-1];
|
||||
int delta_n = current_n - last_n;
|
||||
double delta_i = reference_histogramm[current_n] - reference_histogramm[last_n];
|
||||
double m = delta_i / delta_n;
|
||||
double offset = histogramm_map[last_n];
|
||||
// Fill in the blanks
|
||||
for(int j=last_n; j<=current_n; j++) {
|
||||
int delta_n = j - last_n;
|
||||
histogramm_map[j] = (offset + delta_n*m);
|
||||
logFile << j << " -> " << histogramm_map[j] << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
// Apply the histogramm map (see succeeding Histogramm Adaption)
|
||||
|
||||
|
||||
|
||||
/*
|
||||
int h, s, l;
|
||||
int pixels = working_copy->getImage()->width() * working_copy->getImage()->height();
|
||||
for(int x=0; x<working_copy->getImage()->width(); x++) {
|
||||
for(int y=0; y<working_copy->getImage()->height(); y++) {
|
||||
QColor color = QColor::fromRgb(original->getImage()->pixel(x, y));
|
||||
color.getHsl(&h, &s, &l);
|
||||
l = qRound(histogramm_map[l] * (255/pixels));
|
||||
color.setHsl(h, s, l);
|
||||
working_copy->getImage()->setPixel(x, y, color.rgb());
|
||||
}
|
||||
}*/
|
||||
// Done.
|
||||
free(histogramm_map);
|
||||
free(parts);
|
||||
logFile << "done." << std::endl;
|
||||
renewLogging();
|
||||
updateImageDisplay();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user