Update on my Gimp color management coding efforts
This discussion is connected to the gimp-developer-list.gnome.org mailing list which is provided by the GIMP developers and not related to gimpusers.com.
This is a read-only list on gimpusers.com so this discussion thread is read-only, too.
Update on my Gimp color management coding efforts | Elle Stone | 08 Nov 20:29 |
Update on my Gimp color management coding efforts | Jon Nordby | 08 Nov 22:08 |
Update on my Gimp color management coding efforts | Elle Stone | 10 Nov 20:17 |
Update on my Gimp color management coding efforts | Michael Natterer | 10 Nov 22:54 |
Update on my Gimp color management coding efforts | Elle Stone | 12 Nov 22:55 |
Update on my Gimp color management coding efforts | Tobias Jakobs | 09 Nov 08:05 |
Update on my Gimp color management coding efforts | Liam R E Quin | 09 Nov 16:13 |
Update on my Gimp color management coding efforts | Øyvind Kolås | 09 Nov 16:33 |
Update on my Gimp color management coding efforts
I encountered a couple of stumbling blocks while working on Gimp color management, so I decided to give my brain a rest and work on some other projects. Sometimes enlightenment happens when you stop thinking about a coding problem.
Regarding high bit depth color conversions, the stumbling block is still the background conversions between the sRGB tone response curve and and the linear gamma tone response curve - all those Babl conversions I've mentioned before.
I was hoping that by removing all the deprecated functions the problem with high bit depth color conversion being subverted by the background TRC conversions would be resolved, but it wasn't. I am unsure how to procede, although I have pinpointed exactly where in the Gimp code the Babl functions are called (it's not in the lcms plugin code) and which particular Babl functions are being called.
So I temporarily put the lcms.c plug-in high bit depth color conversion code aside and started working on the code that is used to convert from the image color space to the monitor color space.
In the existing "image color space to monitor color space" code, the image RGB values are converted to 8 bits *before* the RGB values are sent to the code that converts from the image color space to the monitor profile. Which means the monitor display of linear gamma color space images has severely posterized deep shadow detail (the image itself isn't damaged, just the monitor display of the image).
In images that don't have much deep shadow detail, the damage isn't visible. But in images that do have deep shadow detail, the damage is obvious. I can post pictures if anyone is interested.
Shadows are not posterized, even in a linear gamma color space, if you convert from the linear gamma color space to the display color space at 16-bits or higher, and *then* convert from 16-bits to 8-bits to send to the monitor. But you do get posterization if you convert from linear gamma 16-bits to linear gamma 8-bits *before* converting to the monitor display space.
In addition to the monitor display shadow posterization problem, newer high end monitors are using 10- and 12-bit color depth, and I think the Cairo developers are also working on the higher bit depth display code. But at this point Gimp is hard-coded to hand 8-bit values to Cairo.
I've been tracing the "image color space to monitor color space" code execution path, looking for a place to intervene to give the color-space-to-monitor-space lcms profile conversion 16-bit integer or 32-bit floating point values instead of 8-bit values. It turns out that the relevant "image color space to monitor display space" code is spread out over quite a few gimp, babl, and gegl c-code files, and makes heavy use of Cairo-related functions.
I apologize for the long delay in posting an update. Alas, the only enlightenment I have found during that long delay is that to make further progress I will need help from someone well-versed in Gimp/Babl/Gegl/Cairo code.
Kindest regards, Elle Stone
Update on my Gimp color management coding efforts
On 8 November 2012 21:29, Elle Stone wrote:
I was hoping that by removing all the deprecated functions the problem with high bit depth color conversion being subverted by the background TRC conversions would be resolved, but it wasn't. I am unsure how to procede, although I have pinpointed exactly where in the Gimp code the Babl functions are called (it's not in the lcms plugin code) and which particular Babl functions are being called.
Has your work on replacing the deprecated functions found its way into git master?
In the existing "image color space to monitor color space" code, the image RGB values are converted to 8 bits *before* the RGB values are sent to the code that converts from the image color space to the monitor profile. Which means the monitor display of linear gamma color space images has severely posterized deep shadow detail (the image itself isn't damaged, just the monitor display of the image).
I've been tracing the "image color space to monitor color space" code execution path, looking for a place to intervene to give the color-space-to-monitor-space lcms profile conversion 16-bit integer or 32-bit floating point values instead of 8-bit values. It turns out that the relevant "image color space to monitor display space" code is spread out over quite a few gimp, babl, and gegl c-code files, and makes heavy use of Cairo-related functions.
I looked into this code a bit earlier. Here is one way of approaching it:
* Change the lcms-based conversion (modules/display-filter-lcms.c)
from being a generic display filter to be something that takes a
GeglBuffer in and blits into a cairo_surface_t.
* Change the display filter interface to accept a GeglBuffer instead
of a cairo_surface_t. As gimp_color_display_convert_surface is public
API, it should probably become a stub and be marked as deprecated. New
interface could for instance be called
"gimp_color_display_convert_buffer"
* Adapt all the display filter operations (modules/display-filter-*.c)
to the new interface and to working on 32bit floating point. If any of
the operations are no longer useful, now would be the time to drop
them.
* In the use of the display filter stack (in
gimp_display_shell_render), first let the filter stack operate on the
GeglBuffer from the projection (or possibly a copy), and then pass it
to the lcms-based color conversion, and then pass that to cairo.
In the longer term, one can consider making the display filters GEGL operations and the display filter stack a GEGL subgraph.
Update on my Gimp color management coding efforts
Hello Elle!
On Thu, Nov 8, 2012 at 9:29 PM, Elle Stone wrote:
I apologize for the long delay in posting an update. Alas, the only enlightenment I have found during that long delay is that to make further progress I will need help from someone well-versed in Gimp/Babl/Gegl/Cairo code.
I think that is an good idea and I can see four ways to get this happen:
1. Linux Color Management Hackfest 2012 in Brno, Czech Republic http://www.freedesktop.org/wiki/OpenIcc/Events/Hackfest/2012 There you could meet Øyvind Kolås (Pippin)
2. Libre Graphics Meeting 2013 in Madrid, Spain http://libregraphicsmeeting.org/2012/2012/06/lgm-2013-dates-and-venue/ This is the best place to meed more then one Gimp Developer.
3. Fly to a developer. Afaik most Developers are in Europe.
4. Invite an Developer to your place.
My last information is, that the Gimp project has money to sponsor the flights so don't hesitate to ask.
Kindest regards, Tobias
Update on my Gimp color management coding efforts
On Thu, 2012-11-08 at 15:29 -0500, Elle Stone wrote: [...]
In the existing "image color space to monitor color space" code, the image RGB values are converted to 8 bits *before* the RGB values are sent to the code that converts from the image color space to the monitor profile.
And here I am with 11 significant bits in colour specifications according to the video card, and 10-bit colour on the monitor, and 32-bit (10+10+10+2 alpha) visuals in X11...
Update on my Gimp color management coding efforts
On Fri, Nov 9, 2012 at 5:13 PM, Liam R E Quin wrote:
On Thu, 2012-11-08 at 15:29 -0500, Elle Stone wrote: [...]
In the existing "image color space to monitor color space" code, the image RGB values are converted to 8 bits *before* the RGB values are sent to the code that converts from the image color space to the monitor profile.
And here I am with 11 significant bits in colour specifications according to the video card, and 10-bit colour on the monitor, and 32-bit (10+10+10+2 alpha) visuals in X11...
There have been no claims that the current code does something reasonable yet; at the moment I am at the color management hackfest in Brno, among other things arguing for GIMP and other high fidelity applications needs to not go through yet another 8bit -> 8bit LUT with additional quantization problems. :)
The future is already here. It's just not very evenly distributed -- William Gibson @hodefoting _______________________________________________ gimp-developer-list mailing list gimp-developer-list@gnome.org https://mail.gnome.org/mailman/listinfo/gimp-developer-list
Update on my Gimp color management coding efforts
On 11/8/12, Jon Nordby wrote:
Has your work on replacing the deprecated functions found its way into git master?
No. With Mitch's help I did made a patch file (which might be out of date by now, as Gimp keeps changing): http://ninedegreesbelow.com/temp/gimp-lcms-deprecated.html#patch
* Change the lcms-based conversion (modules/display-filter-lcms.c) from being a generic display filter to be something that takes a GeglBuffer in and blits into a cairo_surface_t. * Change the display filter interface to accept a GeglBuffer instead of a cairo_surface_t. As gimp_color_display_convert_surface is public API, it should probably become a stub and be marked as deprecated. New interface could for instance be called "gimp_color_display_convert_buffer"
* Adapt all the display filter operations (modules/display-filter-*.c) to the new interface and to working on 32bit floating point. If any of the operations are no longer useful, now would be the time to drop them.
* In the use of the display filter stack (in gimp_display_shell_render), first let the filter stack operate on the GeglBuffer from the projection (or possibly a copy), and then pass it to the lcms-based color conversion, and then pass that to cairo. --
Jon Nordby - www.jonnor.com
I'm looking forward to taking another look at the monitor display code path. Your suggestions sound very helpful.
When I started looking at Gimp color management I had no idea how very complicated Gimp code is. The light began to dawn as I tracked down the functions that are involved in sending image data to the monitor. Then I traced the function calls from the time Gimp is started until main.c hands control over to Glib (g_main_loop_run). Glib?
I have a sense of how Gimp and Gegl, and Gimp and Babl, interact. Would some kind soul be willing to provide a quick overview of the relationship between Gimp and Glib? And between Gimp and Cairo? I realize that Cairo sends the image data to the screen, but what is the advantage of using Cairo?
Elle
Update on my Gimp color management coding efforts
On Sat, 2012-11-10 at 15:17 -0500, Elle Stone wrote:
On 11/8/12, Jon Nordby wrote:
Has your work on replacing the deprecated functions found its way into git master?
No. With Mitch's help I did made a patch file (which might be out of date by now, as Gimp keeps changing): http://ninedegreesbelow.com/temp/gimp-lcms-deprecated.html#patch
Indeed :) I cleaned up that patch to match GIMP's coding style, fixed some little things, and attached it to:
https://bugzilla.gnome.org/show_bug.cgi?id=662739
Let's continue the patching and patch discussion in this bug. I also added a comment on the patch there.
* Change the lcms-based conversion (modules/display-filter-lcms.c) from being a generic display filter to be something that takes a GeglBuffer in and blits into a cairo_surface_t. * Change the display filter interface to accept a GeglBuffer instead of a cairo_surface_t. As gimp_color_display_convert_surface is public API, it should probably become a stub and be marked as deprecated. New interface could for instance be called "gimp_color_display_convert_buffer"
* Adapt all the display filter operations (modules/display-filter-*.c) to the new interface and to working on 32bit floating point. If any of the operations are no longer useful, now would be the time to drop them.
* In the use of the display filter stack (in gimp_display_shell_render), first let the filter stack operate on the GeglBuffer from the projection (or possibly a copy), and then pass it to the lcms-based color conversion, and then pass that to cairo. --
Jon Nordby - www.jonnor.comI'm looking forward to taking another look at the monitor display code path. Your suggestions sound very helpful.
It does, but it's clearly step 2 (or step n). IMO we should first get the lcms plug-in right so the data GIMP is dealing with is correct in the first place.
When I started looking at Gimp color management I had no idea how very complicated Gimp code is. The light began to dawn as I tracked down the functions that are involved in sending image data to the monitor. Then I traced the function calls from the time Gimp is started until main.c hands control over to Glib (g_main_loop_run). Glib?
I have a sense of how Gimp and Gegl, and Gimp and Babl, interact. Would some kind soul be willing to provide a quick overview of the relationship between Gimp and Glib? And between Gimp and Cairo? I realize that Cairo sends the image data to the screen, but what is the advantage of using Cairo?
GLib and GTK+ were originally developed inside GIMP and then split out to be independent packages ages ago. GTK+ is the user interface toolkit, GLib is a whole framework of cross-platform utility functions, featuring stuff like lists, hash tables, the main loop and tons more.
Cairo is how GTK+ and GIMP render everything for GUI display, its advantage is that before we used wrappers around stone age X11 API which is complete and utter legacy. Cairo is vector based and proper.
For more detailled explanations, google and #gimp IRC are your friends, I haven't seen you on IRC in a long time anyway :)
Regards, --mitch
Update on my Gimp color management coding efforts
On 11/10/12, Michael Natterer wrote:
On Sat, 2012-11-10 at 15:17 -0500, Elle Stone wrote:
On 11/8/12, Jon Nordby wrote:
Has your work on replacing the deprecated functions found its way into git master?
No. With Mitch's help I did made a patch file (which might be out of date by now, as Gimp keeps changing): http://ninedegreesbelow.com/temp/gimp-lcms-deprecated.html#patch
Indeed :) I cleaned up that patch to match GIMP's coding style, fixed some little things, and attached it to:
https://bugzilla.gnome.org/show_bug.cgi?id=662739
Let's continue the patching and patch discussion in this bug. I also added a comment on the patch there.
* Change the lcms-based conversion (modules/display-filter-lcms.c) from being a generic display filter to be something that takes a GeglBuffer in and blits into a cairo_surface_t. * Change the display filter interface to accept a GeglBuffer instead of a cairo_surface_t. As gimp_color_display_convert_surface is public API, it should probably become a stub and be marked as deprecated. New interface could for instance be called "gimp_color_display_convert_buffer"
* Adapt all the display filter operations (modules/display-filter-*.c) to the new interface and to working on 32bit floating point. If any of the operations are no longer useful, now would be the time to drop them.
* In the use of the display filter stack (in gimp_display_shell_render), first let the filter stack operate on the GeglBuffer from the projection (or possibly a copy), and then pass it to the lcms-based color conversion, and then pass that to cairo. --
Jon Nordby - www.jonnor.comI'm looking forward to taking another look at the monitor display code path. Your suggestions sound very helpful.
It does, but it's clearly step 2 (or step n). IMO we should first get the lcms plug-in right so the data GIMP is dealing with is correct in the first place.
I completely agree that getting the lcms.c plugin to work is the first priority, though hopefully "n" is very close to 2.
By the end of this week I will have whittled my "to do" list down to where Gimp color management is back near the top of the list, so I'll be stopping by IRC more regularly. I think I understand your bug report comment and can provide context.
Cheers, Elle