[Digikam-devel] [Bug 170169] New: Idea for high quality 8-bit curve adjustments

Dik Takken d.h.j.takken at xs4all.nl
Mon Sep 1 10:10:34 BST 2008


http://bugs.kde.org/show_bug.cgi?id=170169

           Summary: Idea for high quality 8-bit curve adjustments
           Product: digikamimageplugins
           Version: unspecified
          Platform: Gentoo Packages
        OS/Version: Linux
            Status: NEW
          Severity: wishlist
          Priority: NOR
         Component: Adjust Curves
        AssignedTo: digikam-devel at kde.org
        ReportedBy: d.h.j.takken at xs4all.nl


Version:           0.9.4 (using KDE 3.5.9)
OS:                Linux
Installed from:    Gentoo Packages

When doing curve adjustment on 8-bit images, the histogram will get damaged
pretty quickly: Holes appear, which leads to banding effects.

This problem might be fixable by doing the calculation in 16-bit and using
noise. Let me explain. 

When converting an 8-bit image to 16-bit, the 16-bit image will still have 256
discrete brightness levels. So, the histogram of the 16-bit image looks like
uniformly distributed spikes, placed (2^16)/256 = 256 apart. 

By adding noise with an amplitude of 256, the 16-bit histogram will become
continuous: The spaces between spikes are gone. Applying a curve will yield a
relatively smooth histogram, which can be converted back to 8-bit.

In pseudo C code, applying a curve to a 8-bit brightness value looks like this:

INT8 Curve8(INT8 inputvalue)
{
value16bit = ((INT16)(inputvalue)) + Random() - 128;

return (INT8)(Curve16(value16bit));
}

Where Random() is a random value between 0 and 255 and Curve16() is the 16-bit
version of the adjust curves algorithm. Some bounds checking should be added to
make sure the addition and subtraction will not yield funny results near the
black and white ends of the scale.

At least the above technique allows the user to choose between banding and
noise. The technique might also be useful in other plugins that tend to tear
8-bit histograms apart.


-- 
Configure bugmail: http://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the Digikam-devel mailing list