Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[RFC] LUT-free `RGB`->`XYZ` conversion

Open
#592 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Refactor
Clarity
Needs clarification
Activity status
Active
Tech stack
julia

Research direction

Start by reading issues #351 and #587, then locate the current LUT-based RGB{N0f8}→XYZ{Float32} conversion entry point. Benchmark the existing CPU path and investigate a LUT-free alternative for GPU suitability; done means documenting the CPU slowdown and whether the trade-off is acceptable.

Written by the indexing model from the issue text.

Description

help wanted

I was working on speeding up the RGB<->XYZ conversion 7 years ago. (cf. issue #351)
The problem is v^2.4 and v^(1/2.4) used in the so-called gamma curve of sRGB.

In the end, for the RGB{N0f8}→XYZ{Float32} conversion, I chose to use LUTs.
Using LUTs is probably the fastest approach for CPU computation.

For GPU computation as well, a Float32 × 256 LUT is small enough that I don't think it would become a bottleneck.
However, when using a LUT, some form of instruction is required to make it shareable on the GPU. (cf. issue #587)
Since this package deals with colors rather than images, AFAIK there is no way for the method or compiler to determine whether the data is in a GPU array or a CPU array.
(From a long-term perspective, we might end up implementing ColorsGPUCompilerExt etc., but it is too large a project for me to shoulder alone.)

If we were to stop using a LUT in order to improve GPU suitability, how much slowdown on the CPU would be acceptable?

Edit:
Further consideration is still needed before deciding whether to make the RGB{N0f8} implementation LUT-free or to provide something like @device_override for each GPU package.

On the other hand, the current implementation for RGB{Float32} is not particularly fast and is also somewhat inaccurate.
Therefore, I am considering updating it to a LUT-free algorithm that produces 0 ULP error for all 256 inputs that can be represented by N0f8, when used as RGB{Float32} inputs.

This would make it possible to support conversions on GPU by explicitly converting RGB{N0f8} to RGB{Float32}.

Dominant language
Julia
Stars
226
Forks
53
Avg merge
3d 3h
Merged PRs (30d)
5

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from JuliaGraphics/Colors.jl

All issues in JuliaGraphics/Colors.jl

Similar issues

More Julia issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.