[Bug 170170] New: High quality 8 to 16-bit conversion

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

[Bug 170170] New: High quality 8 to 16-bit conversion

Dik Takken-2
http://bugs.kde.org/show_bug.cgi?id=170170

           Summary: High quality 8 to 16-bit conversion
           Product: digikam
           Version: 0.9.4
          Platform: Gentoo Packages
        OS/Version: Linux
            Status: NEW
          Severity: wishlist
          Priority: NOR
         Component: Image Editor
        AssignedTo: [hidden email]
        ReportedBy: [hidden email]


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

In Bug 170169, I posted an idea to use noise to obtain better 16-bit images
from 8-bit images. The same idea can be used to improve the 8/16 bit conversion
function in DigiKam.


--
Configure bugmail: http://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel
Reply | Threaded
Open this post in threaded view
|

[Bug 170170] High quality 8 to 16-bit conversion (histogram repair)

Gilles Caulier-4
https://bugs.kde.org/show_bug.cgi?id=170170


Gilles Caulier <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|High quality 8 to 16-bit    |High quality 8 to 16-bit
                   |conversion                  |conversion (histogram
                   |                            |repair)




--- Comment #1 from Gilles Caulier <caulier gilles gmail com>  2010-01-26 09:37:29 ---
Definitively, this is the right way.

http://www.powerretouche.com/Histogram_Repair_plugin_tutorial.htm

I need an algorithm to do it. I don't found yet something in open source world.

All suggestion are fine. thanks in advance

Gilles Caulier

--
Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel
Reply | Threaded
Open this post in threaded view
|

[Bug 170170] High quality 8 to 16-bit conversion (histogram repair)

Dik Takken-2
In reply to this post by Dik Takken-2
https://bugs.kde.org/show_bug.cgi?id=170170





--- Comment #2 from Dik Takken <d h j takken xs4all nl>  2010-01-26 11:46:25 ---
I expect (actually I'm quite convinced) that their "algorithm" is adding noise,
like I explained in Bug 170169. Very simple, very effective.

--
Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel
Reply | Threaded
Open this post in threaded view
|

[Bug 170170] High quality 8 to 16-bit conversion (histogram repair)

Gilles Caulier-4
In reply to this post by Dik Takken-2
https://bugs.kde.org/show_bug.cgi?id=170170


Gilles Caulier <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[hidden email]




--- Comment #3 from Gilles Caulier <caulier gilles gmail com>  2010-01-26 11:49:44 ---
Really ? And which type of noise ?

If noise is added, it will be visible to the image. Right ? This can be
confirmed to test photoshop plugin ?

Gilles Caulier

--
Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel
Reply | Threaded
Open this post in threaded view
|

[Bug 170170] High quality 8 to 16-bit conversion (histogram repair)

Dik Takken-2
In reply to this post by Dik Takken-2
https://bugs.kde.org/show_bug.cgi?id=170170





--- Comment #4 from Dik Takken <d h j takken xs4all nl>  2010-01-26 12:11:35 ---
The noise is very subtle, just enough to fill the gaps in the histogram. On a
8-bit display, it is even impossible to see it. Only if you apply curves to the
image, the noise may become visible, provided that the image itself is clean.
You might try it on an 8-bit gradient. Create an 8-bit gradient, convert to
16-bit, repair the histogram and apply some extreme curve to it. If the
gradient repair plugin uses noise, you will see it now. Can anyone try this?

The algorithm for repairing the histogram after 8 -> 16 bit conversion looks
like this:

function RepairHistogram()
{
  for every pixel do
  {
    for every channel do
    {
      Pixel[channel].value += ( Random() % 256 )
    }
  }
}

Ideally, the histogram repair should be done automatically when converting from
8 to 16 bit. Image filtering plugins (like curves) should temporarily convert
the image to 16-bits and apply the noise to produce high quality 8-bit filtered
images.

--
Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel
Reply | Threaded
Open this post in threaded view
|

[Bug 170170] High quality 8 to 16-bit conversion (histogram repair)

"Jens Müller"
In reply to this post by Dik Takken-2
https://bugs.kde.org/show_bug.cgi?id=170170





--- Comment #5 from Jens Mueller <tschenser gmx de>  2010-01-30 10:42:21 ---
Created an attachment (id=40376)
 --> (http://bugs.kde.org/attachment.cgi?id=40376)
preview of convert with additional noise

Warning: this patch is not intended to be merged, it only shows what is ment
and how it will look.

When converting up to 16bit this patch fills the gaps between the computated
16bit values. But there is currently one problem: All gaps are filled from the
next lower value with noise (to preserve reversible 16bit->8bit conversation
after) - the only value can not be spread is highest, 65535, so the weightened
count of 65535 to any other value changed.

Jens

--
Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel
Reply | Threaded
Open this post in threaded view
|

[Bug 170170] High quality 8 to 16-bit conversion (histogram repair)

Gilles Caulier-4
In reply to this post by Dik Takken-2
https://bugs.kde.org/show_bug.cgi?id=170170





--- Comment #6 from Gilles Caulier <caulier gilles gmail com>  2010-02-03 14:47:06 ---
Jens,

You method scan all pixels image to add noise everywhere.

It will be better to scan histogram, find hole in graph and identify place in
image where holes are located to limit noise to add in image.

Dik,

Have you tried this patch on your computer and test if globaly, the noisify
method is right here ?

Gilles Caulier

--
Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel
Reply | Threaded
Open this post in threaded view
|

[Bug 170170] High quality 8 to 16-bit conversion (histogram repair)

Dik Takken-2
In reply to this post by Dik Takken-2
https://bugs.kde.org/show_bug.cgi?id=170170





--- Comment #7 from Dik Takken <d h j takken xs4all nl>  2010-02-03 15:06:52 ---
You MUST add noise everywhere, because every pixel has holes... It's a
statistical thing. I did not test the patch, I can't run SVN checkouts at the
moment. Testing is easy though. Just check if:

* The histogram is smooth
* The noise is invisible
* No clipping occurs
* The images degrades gracefully (no banding) when applying a steep curve

If the above checks out, it works.

--
Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel
Reply | Threaded
Open this post in threaded view
|

[Bug 170170] High quality 8 to 16-bit conversion (histogram repair)

Dik Takken-2
In reply to this post by Dik Takken-2
https://bugs.kde.org/show_bug.cgi?id=170170





--- Comment #8 from Dik Takken <d h j takken xs4all nl>  2010-02-03 15:27:51 ---
I just took a quick peek at the patch, and I realized that this patch will make
the image slightly brighter. Statistically, it will add 128 to the value of
every pixel. I don't know if the brightening will be visible, but here is an
improved algorithm:

function RepairHistogram()
{
  for every pixel do
  {
    for every channel do
    {
      // Add noise:
      Pixel[channel].value += ( Random() % 256 ) - 128

      // Fix clipping:
      Pixel[channel].value = MAX(Pixel[channel].value, 0)
      Pixel[channel].value = MIN(Pixel[channel].value, 65535)
    }
  }
}

--
Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel
Reply | Threaded
Open this post in threaded view
|

[Bug 170170] High quality 8 to 16-bit conversion (histogram repair)

"Jens Müller"
In reply to this post by Dik Takken-2
https://bugs.kde.org/show_bug.cgi?id=170170


Jens Mueller <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[hidden email]




--- Comment #9 from Jens Mueller <tschenser gmx de>  2010-02-04 18:33:39 ---
@DIK: yes, the patch will make the image slightly brighter. This is to preserve
full reversibleness with current code when doing a 16bit->8bit downscale again.
So you can do as many up/down conversations as you want, the orginal image will
stay the same and you do not lost any information.

@Gilles: As DIK already said, you must add noise to every pixel and every color
channel. This noise will be clipped when doing 16bit->8bit downscale again. So
again, there is no information loss. I know, this sounds a bit weird for the
first time. ;o)

--
Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel
Reply | Threaded
Open this post in threaded view
|

[Bug 170170] High quality 8 to 16-bit conversion (histogram repair)

"Jens Müller"
In reply to this post by Dik Takken-2
https://bugs.kde.org/show_bug.cgi?id=170170





--- Comment #10 from Jens Mueller <tschenser gmx de>  2010-09-23 20:07:39 ---
I starred again at this.

Currently we have:

get8from16(  0..256) = 0
get8from16(257..513) = 1
get8from16(65278..65534) = 254
get8from16(65535) = 255

As you can see the last value is only build from one source value where are the
others build from an interval.

What we do want to have is a uniform quantization:

get8from16(  0..255) = 0
get8from16(256..511) = 1
get8from16(65024..65279) = 254
get8from16(65280..65535) = 255

and the reverse:

get16from8(0) = 0..255
get16from8(1) = 256..511
get16from8(254) = 65024..65279
get16from8(255) = 65280..65535

therefore we have to use a grain of salt.

--
Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel
Reply | Threaded
Open this post in threaded view
|

[Bug 170170] High quality 8 to 16-bit conversion (histogram repair)

"Jens Müller"
In reply to this post by Dik Takken-2
https://bugs.kde.org/show_bug.cgi?id=170170





--- Comment #11 from Jens Mueller <tschenser gmx de>  2010-09-23 20:08:39 ---
Created an attachment (id=51915)
 --> (http://bugs.kde.org/attachment.cgi?id=51915)
patch for the suggested change

--
Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel
Reply | Threaded
Open this post in threaded view
|

[Bug 170170] High quality 8 to 16-bit conversion (histogram repair)

"Jens Müller"
In reply to this post by Dik Takken-2
https://bugs.kde.org/show_bug.cgi?id=170170


Jens Mueller <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #40376|0                           |1
        is obsolete|                            |




--
Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel
Reply | Threaded
Open this post in threaded view
|

[Bug 170170] High quality 8 to 16-bit conversion (histogram repair)

Gilles Caulier-4
In reply to this post by Dik Takken-2
https://bugs.kde.org/show_bug.cgi?id=170170





--- Comment #12 from Gilles Caulier <caulier gilles gmail com>  2010-09-24 15:42:56 ---
Thanks Jens. i tested it, and it work perfectly. Look my screenshot :

http://www.flickr.com/photos/digikam/5020489802/

Gilles Caulier

--
Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel
Reply | Threaded
Open this post in threaded view
|

[Bug 170170] High quality 8 to 16-bit conversion (histogram repair)

Gilles Caulier-4
In reply to this post by Dik Takken-2
https://bugs.kde.org/show_bug.cgi?id=170170


Gilles Caulier <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




--- Comment #13 from Gilles Caulier <caulier gilles gmail com>  2010-09-24 15:44:14 ---
SVN commit 1179081 by cgilles:

New histogram repair algorithm written by Jens Muller to convert 8 bits image
to 16 bits, to limit histogram holes during conversion.
BUGS: 170170


 M  +23 -2     dimg.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1179081

--
Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel