[GrafX2] #166: Display colour correction with lookup table (or ICC profile)

8 views
Skip to first unread message

GrafX2

unread,
Aug 25, 2021, 4:56:04 PMAug 25
to gra...@googlegroups.com
#166: Display colour correction with lookup table (or ICC profile)
------------------------------+------------------------
Reporter: wyattfward@… | Owner: pulkomandy
Type: enhancement | Status: new
Priority: minor | Milestone:
Component: GrafX2 | Version: 2.9WIP
Keywords: color management |
------------------------------+------------------------
This is just a wishlist item as much as anything, but I'd like it if (for
the ports where it is viable) there was a way to use either a 3D lookup
table image or an ICC profile with a library like LittleCMS to perform
color correction for screens. My laptop, for instance, has a display which
only covers about 60% of the sRGB colour gamut, and many colours on it
look quite different without correction than they do on an sRGB CRT or LCD
panel.

Not all colour correction can currently be done in GPU hardware on most
operating systems; they typically only support a one dimensional lookup
table that can be used to correct white point and gamma. To get something
closer to how an image would look on an ideal display, colour managed
software utilizes a three dimensional lookup table to transform colours
just before displaying.

Since Grafx2 uses an indexed 256 colour palette, it could likely just
achieve this by taking the image's palette, feeding it as a raster image
into LittleCMS, and using the resulting image to translate each colour
from its raw actual value into a displayed one.

To accomplish this a dialogue would have to be added to either select an
ICC profile, or to load a manually created lookup table. If you want to
experiment with them, I have written a Python program that uses LittleCMS,
and can apply transformations on image files. This could be used to
generate palette colour translation tables if needed.
My repository also contains a couple colour profiles from my machines: my
Dell u2412M, which only needs minimal corrections, and my Thinkpad X201
Tablet, which needs major corrections (and thus transformations on it
yield more dramatic results).

[https://gitlab.com/wyatt8740/icc-burn]

The colour-corrected image is on the right; what grafx2 shows is on the
left (on my Thinkpad; on the Dell the two images would be virtually
indistinguishable between each other):
[[Image(https://i.imgur.com/vj7ohg4g.jpg)]]
Full resolution https://i.imgur.com/vj7ohg4.jpg

--
Ticket URL: <http://pulkomandy.tk/projects/GrafX2/ticket/166>
GrafX2 <http://pulkomandy.tk/projects/GrafX2>
The ultimate 256-color painting program

GrafX2

unread,
Oct 9, 2021, 10:38:10 AMOct 9
to gra...@googlegroups.com
#166: Display colour correction with lookup table (or ICC profile)
---------------------------+------------------------------
Reporter: wyattfward@… | Owner: pulkomandy
Type: enhancement | Status: new
Priority: minor | Milestone:
Component: GrafX2 | Version: 2.9WIP
Resolution: | Keywords: color management
---------------------------+------------------------------

Comment (by Thomas Bernard):

Isn't color profiles managed at the OS level ?
Which version of GrafX2 have you tried ? The results could be a bit
different depending on which "API" is used (SDL 1.2, SDL 2, Win32 GDI or
X11)

--
Ticket URL: <http://pulkomandy.tk/projects/GrafX2/ticket/166#comment:1>

GrafX2

unread,
Oct 19, 2021, 11:05:21 AMOct 19
to gra...@googlegroups.com
#166: Display colour correction with lookup table (or ICC profile)
---------------------------+------------------------------
Reporter: wyattfward@… | Owner: pulkomandy
Type: enhancement | Status: new
Priority: minor | Milestone:
Component: GrafX2 | Version: 2.9WIP
Resolution: | Keywords: color management
---------------------------+------------------------------

Comment (by yrizoud@…):

As I understand it, the goal would be to edit an image on a platform, but
simulate the rendering that you would get if the image was dispayed on
another platform.

For example if you had the exact ICC profile of a Nintendo DS, and you
converted your drawing environmnent to it, the sprites that you draw for a
homebrew would transfer more faithfully. No more surprises of "oh these
dark shades are too similar when viewed on the real screen".

--
Ticket URL: <http://pulkomandy.tk/projects/GrafX2/ticket/166#comment:2>

GrafX2

unread,
Oct 27, 2021, 1:16:20 PMOct 27
to gra...@googlegroups.com
#166: Display colour correction with lookup table (or ICC profile)
---------------------------+------------------------------
Reporter: wyattfward@… | Owner: pulkomandy
Type: enhancement | Status: new
Priority: minor | Milestone:
Component: GrafX2 | Version: 2.9WIP
Resolution: | Keywords: color management
---------------------------+------------------------------

Comment (by wyattfward@…):

This is exactly the interpretation I was going for.

In my case, my laptop/tablet (thinkpad x201 tablet) screen does not cover
the full sRGB gamut, and many colours look desaturated; additionally, some
colors are just wrong; some violets actually look blue on my screen. With
a 3D lookup table (either contained in an ICC profile, or in a shader
texture/cube file/some other format), the colors can be made to render at
least ''more'' correctly than they otherwise would. It certainly results
in far fewer surprises when I move from my tablet to my desktop (which has
an sRGB monitor) or my Amiga (which is using an RGB CRT with EBU
phosphors).

It basically makes it easier to know what color I'm actually working with.

Thoughts on some implementation strategies:
Most 3D LUT's I see are 64x64x64 or smaller (32x32x32, or even 16x16x16),
so they aren't 1:1 with the full range of possible RGB colours. Therefore,
interpolation is used. There's a document that does an okay job explaining
the design and use of a 3D lookup table with interpolation, should there
be any desire to write one from scratch. I don't really recommend this.
It's still useful to understanding the concepts, though.
https://spie.org/samples/PM159.pdf

There are libraries that exist to handle this sort of thing. Little CMS
among them. The documentation is thorough, but in my opinion not
particularly friendly to people getting started. There are sample programs
included in the repository, though.
https://www.littlecms.com/LittleCMS2.12%20tutorial.pdf
https://www.littlecms.com/LittleCMS2.12%20API.pdf

Most lookup tables in ICC profiles translate from the (linear) L*A*B
colorspace to some other color space, but it would greatly simplify things
and increase performance at run-time if you required users to generate a
LUT that goes from sRGB to their desired space directly and provide that.
Argyll can do this (specifically, the 'collink' utility), as can
DisplayCAL which acts as a wrapper around collink for this purpose.

IRIDAS/Adobe Cube files have a public specification and are a plaintext
format; other options include parsing an ICC profile, although not all ICC
profiles contain three dimensional XYZ lookup tables. They can be
generated by 'collink' from Argyll.
https://wwwimages2.adobe.com/content/dam/acom/en/products/speedgrade/cc/pdfs
/cube-lut-specification-1.0.pdf

--
Ticket URL: <http://pulkomandy.tk/projects/GrafX2/ticket/166#comment:3>
Reply all
Reply to author
Forward
0 new messages