First things first. The C code for gegl operation I use here that prints the 
pixels in CIE xyY color space is below.
I apologize that it's an unnecessary composer3 class, but that's what I had 
handy as a template.
I also attached a very small (3x3) test image `33time.xcf`.

When first opened, the image is in Built-in sRGB and the top row is pure rgb, 
that is 255,0,0; 0,255,0; 0,0,255. And when running my small gegl operation, I 
get this stdout in CIExyY color space:

Input pixels  x=0.653898, y=0.321709, Y=0.222488
Input pixels  x=0.323680, y=0.580968, Y=0.716904
Input pixels  x=0.138084, y=0.056409, Y=0.060608
...

Which seems roughly correct (though not exactly comforming to the sRGB 
standard, which should be 0.64, 0.33, 0.2126 for the Red - that is also weird).
Then I convert the image to ProPhoto RGB (for example) color space. Now the 
"pure" sRGB colors are no longer represented as pure values - but that is to be 
expected - that is how color spaces work. So far so good.
The problem comes when I try to peep at the xyY values using my operation:

Input pixels  x=0.576892, y=0.363497, Y=0.144828
Input pixels  x=0.356573, y=0.513024, Y=0.668290
Input pixels  x=0.175974, y=0.085000, Y=0.083105
...

Those seem to differ as well, which is wrong as CIExyY color space is a profile 
connection space and the values there should be objective values not burdened 
by any device profile/working space.
That is my problem. Why does GIMP/GEGL seem to change the fundamental color as 
well besides just its RGB representation when converting between profiles? 
(Rendering intents seem to have no significant change) How do I make it behave 
correctly? Have I misunderstood something? How do I get the proper CIExyY 
values?

Thanks, Marek

=== stdout of the session:
$ gimp
Gtk-Message: 12:06:57.013: Failed to load module "appmenu-gtk-module"

(gimp:253037): Gtk-WARNING **: 12:06:57.017: Unable to locate theme engine in 
module_path: "adwaita",
gimp_color_transform_new: using babl for 'GIMP built-in sRGB' -> 'sRGB'
gimp_color_transform_new: using babl for 'GIMP built-in sRGB' -> 'sRGB'
gimp_color_transform_new: using babl for 'GIMP built-in sRGB' -> 'sRGB'
gimp_color_transform_new: using babl for 'GIMP built-in sRGB' -> 'sRGB'
gimp_color_transform_new: using babl for 'GIMP built-in sRGB' -> 'sRGB'
gimp_color_transform_new: using babl for 'GIMP built-in sRGB' -> 'sRGB'
gimp_color_transform_new: using babl for 'GIMP built-in D65 Linear Grayscale' 
-> 'sRGB'
gimp_color_transform_new: using babl for 'GIMP built-in sRGB' -> 'sRGB'
gimp_color_transform_new: using babl for 'GIMP built-in sRGB' -> 'sRGB'
using gegl copy
using gegl copy
---
Input pixels  x=0.653898, y=0.321709, Y=0.222488
Input pixels  x=0.323680, y=0.580968, Y=0.716904
Input pixels  x=0.138084, y=0.056409, Y=0.060608
---
Input pixels  x=0.164499, y=0.090740, Y=0.068458
Input pixels  x=0.322666, y=0.549651, Y=0.470922
Input pixels  x=0.598590, y=0.323715, Y=0.166370
---
Input pixels  x=0.333333, y=0.333333, Y=1.000000
Input pixels  x=0.333333, y=0.333333, Y=0.212231
Input pixels  x=0.345703, y=0.358538, Y=0.000000
gimp_color_transform_new: using babl for 'GIMP built-in sRGB' -> 'ProPhoto RGB'
void gimp_gegl_convert_color_profile(GeglBuffer*, const GeglRectangle*, 
GimpColorProfile*, GeglBuffer*, const GeglRectangle*, GimpColorProfile*, 
GimpColorRenderingIntent, gboolean, GimpProgress*): converting buffer took 
0.0001 seconds
gimp_color_transform_new: using babl for 'ProPhoto RGB' -> 'sRGB'
gimp_color_transform_new: using babl for 'ProPhoto RGB' -> 'sRGB'
gimp_color_transform_new: using babl for 'ProPhoto RGB' -> 'sRGB'
gimp_color_transform_new: using babl for 'ProPhoto RGB' -> 'GIMP built-in sRGB'
gimp_color_transform_new: using babl for 'GIMP built-in sRGB' -> 'ProPhoto RGB'
gimp_color_transform_new: using babl for 'ProPhoto RGB' -> 'GIMP built-in sRGB'
gimp_color_transform_new: using babl for 'GIMP built-in sRGB' -> 'ProPhoto RGB'
using gegl copy
using gegl copy
---
Input pixels  x=0.576892, y=0.363497, Y=0.144828
Input pixels  x=0.356573, y=0.513024, Y=0.668290
Input pixels  x=0.175974, y=0.085000, Y=0.083105
---
Input pixels  x=0.193397, y=0.109573, Y=0.066733
Input pixels  x=0.354258, y=0.493454, Y=0.393717
Input pixels  x=0.526750, y=0.360529, Y=0.102815
---
Input pixels  x=0.333333, y=0.333333, Y=1.000000
Input pixels  x=0.333333, y=0.333333, Y=0.149960
Input pixels  x=0.345703, y=0.358538, Y=0.000000
gimp_color_transform_new: using babl for 'ProPhoto RGB' -> 'sRGB'

=== print-pixels.c
#define GETTEXT_PACKAGE "gegl"

#include <glib/gi18n-lib.h>
#include <stdio.h>

#ifdef GEGL_PROPERTIES

#else

#define GEGL_OP_POINT_COMPOSER3
#define GEGL_OP_NAME     print_pixels
#define GEGL_OP_C_SOURCE print-pixels.c

#include "gegl-op.h"

static void
prepare (GeglOperation *operation)
{
    const Babl *space = gegl_operation_get_source_space (operation, "input");
    const Babl *format;
    format  = babl_format_with_space ("CIE xyY float", space);
    gegl_operation_set_format (operation, "input", format);
    gegl_operation_set_format (operation, "aux", format);
    gegl_operation_set_format (operation, "aux2", format);
    gegl_operation_set_format (operation, "output", format);
}

static gboolean
process (GeglOperation       *operation,
     void                *in_buf,
     void             *aux_buf,
     void             *aux2_buf,
     void                *out_buf,
     glong                n_pixels,
     const GeglRectangle *roi,
     gint                 level)
{
    GeglProperties *o = GEGL_PROPERTIES (operation);
    gfloat *in   = in_buf;
    printf("---\n");
    for (int i = 0; i < n_pixels; i++)
    {
        printf("Input pixels  x=%f, y=%f, Y=%f\n", in[0], in[1], in[2]);
        in += 3;
    }

    return TRUE;
}

static void
gegl_op_class_init (GeglOpClass *klass)
{
    GeglOperationClass               *operation_class;
    GeglOperationPointComposer3Class *point_composer_class;

    operation_class      = GEGL_OPERATION_CLASS (klass);
    point_composer_class = GEGL_OPERATION_POINT_COMPOSER3_CLASS (klass);

    operation_class->prepare = prepare;
    operation_class->threaded = TRUE;
    operation_class->opencl_support = FALSE;

    point_composer_class->process = process;

    gegl_operation_class_set_keys (operation_class,
        "name"       , "gegl:print-pixels",
        "title",       _("Print Pixels"),
        "categories" , "color",
        "description", _("Print all pixels in an image."),
        NULL);
}

#endif
_______________________________________________
gimp-developer-list mailing list
List address:    gimp-developer-list@gnome.org
List membership: https://mail.gnome.org/mailman/listinfo/gimp-developer-list
List archives:   https://mail.gnome.org/archives/gimp-developer-list

Reply via email to