[Digikam-devel] [Bug 304811] Offer a "stretch histogram" functionality to automatically adjust brightness & gamma

Alain Knaff kde at kde.lka.org.lu
Wed Aug 8 21:17:29 BST 2012


https://bugs.kde.org/show_bug.cgi?id=304811

--- Comment #2 from Alain Knaff <kde at kde.lka.org.lu> ---
I dunno... the histogram is displayed, so at some point it's probably stored
somewhere.
Assuming the histogram x axis goes from 0 to 99, maybe we could do something as
follows:

int min=-1;
int max=-1;
int i;
for(i=0; i<=99; i++) {
  if(histogram[i] != 0) {
    min=i;
    break;
 }
}

for(i=99; i>=0; i++) {
  if(histogram[i] != 0) {
    max=i;
    break;
 }
}

brightnessCorrection = 100-(min+max);
contrastCorrection = 100-(max-min);

I don't really know the digikam code that much, so maybe the numbers (bounds)
probably need adjustment and/or scaling to make everything fit. The goal here
is to tweak contrast/brightness such that the black part of the histogram
stretches enough to fill the available space, without any black part being
"cut" off, and without any part where y is 0 (or very small) left over near the
bounds.

-- 
You are receiving this mail because:
You are the assignee for the bug.



More information about the Digikam-devel mailing list