Re: [Gimp-developer] Gegl gaussian blur gamma error

On 8/5/12, Øyvind Kolås <pippin gimp org> wrote:
> On Sat, Aug 4, 2012 at 11:44 PM, Elle Stone <l elle stone gmail com> wrote:
>> While working on the article, I noticed that the Gimp Gegl gaussian
>> blur nicely blurs *regular* sRGB images without the darkening
>> artifacts that normally accompany gaussian blurring. But when used on
>> a linear gamma image, the Gegl gaussian blur makes it look like the
>> image was actually blurred in a gamma=0.45 color space (there are
>> "lightening" artifacts). So similar to the problem when opening a
>> 16-bit tif, there seems to be a strange gamma error involved.
> How do you create a linear gamma image to do your tests? The only way
> you actually can do that is to open a PNG image that is 16 bit (or to
> create a 16bit / 32bit image in the first place).

The way I created the linear gamma sRGB test images was as follows:
*Create an image of the appropriate size with Gimp.
*Set the precision to 16 bits.
*Assign the profile I wanted to use, which was a linear gamma version of sRGB.
*Create the test image.
*Export as a 16-bit png.

The first test image I created was composed of color blocks, all of
which had R, G, and B values of either 255 or 0 (that is, 100%
saturated, 100% bright magenta, yellow, teal, green, blue, and red,
plus black and white).

> If you take a gamma
> encoded image and change it's profile to be "linear light" with lcms
> you are changing the pixel values of the image,

Terminology can be confusing. Just to make sure we are talking about
the same thing, to me, "linear light" refers to a rather odd blend
mode. But I'm pretty sure that you use the phrase to mean any RGB
profile with a linear gamma tone response curve, or perhaps you mean
specifically a linear gamma version of sRGB.

By "change" do you mean "convert to" or "apply/assign" an ICC profile?
Regardless, as long as the primaries are still the sRGB primaries, if
all the R, G, and B values are either 255 or 0 (as in my first test
image), starting with a linear gamma sRGB profile and either
*applying* a regular sRGB profile or *converting* to a regular sRGB
profile, produces an image in which none of the image R, G, and B
values have changed.

Otherwise, if any of the RGB values are not either 255 or 0, then of
course the RGB values change when you *convert* from linear gamma sRGB
to regular sRGB. And *applying* keeps the values the same but changes
the "meaning" of the RGB values.

> but the meta data
> passed around in terms of bablformats in the GeglBuffer will still
> state that this is sRGB data, and when gegl:gaussian-blur is blurring
> it that sRGB data will be converted to linear light data for the
> actual blurring.

Are you saying is that babl/gegl always acts as if any image opened by
Gimp is really in the regular sRGB color space, with sRGB's peculiar
"almost gamma=2.2" tone response curve? Or that if the image is
created by Gimp, even after a diffferent ICC profile is assigned, that
babl/gegl still assumes that the image is an sRGB image, with the
peculiar sRGB tone response curve?

What I would have assumed would happen, is that "behind the scenes"
gegl/babl creates (something like a) linear scRGB version of the image
(by literally converting the image *from* whatever RGB color space it
happens to be in *to* the scRGB color space) and then applies the
gegl/babl gaussian blur to the *converted* image (not to the original

If what I just described is what really happened, then there would be
no gamma error during the gegl gaussian blur. The linear gamma image
would be converted to linear scRGB "behind the scenes", blurred
correctly, and converted back to the original linear gamma profile
upon exporting the image. And the regular gamma image would be
converted to linear scRGB "behind the scenes", blurred correctly, and
converted back to the original regular gamma profile upon exporting
the image.

But what really seems to be happening is that gegl/babl assumes all
images have the sRGB not-quite-gamma-2.2 tone response curve,
regardless of the image profile's actual tone response curve. In other
words, there doesn't seem to be any "behind the scenes" converting
*from* the ICC profile the image has upon opening, *to* the babl/gegl
internal working space, before the gegl operation is applied to the

> For newly created images in GIMP-2.9 the buffers are created as sRGB
> (gamma encoded), since this is where gamma encoding makes sense;
> giving higher fidelity in the shadows. For higher bitdepths GIMP-2.9
> creates linear light buffers.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]