Skip to content

Add OKLab color space support#43

Merged
adamjtaylor merged 1 commit into
mainfrom
30-oklab-colorspace
Jan 13, 2026
Merged

Add OKLab color space support#43
adamjtaylor merged 1 commit into
mainfrom
30-oklab-colorspace

Conversation

@adamjtaylor
Copy link
Copy Markdown
Owner

@adamjtaylor adamjtaylor commented Jan 13, 2026

Summary

  • Adds OKLab color space as a new colormap option alongside existing LAB and RGB
  • OKLab provides superior perceptual uniformity where Euclidean distance directly corresponds to perceived color difference (no need for complex CIEDE2000 calculations)
  • Addresses known CIELAB non-uniformities, particularly in the blue-purple range

Changes

  • ucie.py: Added generate_oklab_grid(), oklab_to_rgb_vectorized(), updated get_target_hull() and optimize_embedding() to support OKLAB target
  • core.py: Added assign_colours_oklab() function, added OKLAB to CLI choices and default 3D colormap list
  • init.py: Exported assign_colours_oklab
  • tests: Added comprehensive tests for all new OKLab functionality

Usage

# Use OKLab colormap
paint_miniature input.tiff output.png --colormap OKLAB

# Generate all 3D colormaps (now includes OKLAB)
paint_miniature input.tiff output.png --colormap ALL --n_components 3

Test plan

  • All existing tests pass
  • New OKLab tests pass (test_assign_colours_oklab, test_generate_oklab_grid, test_oklab_to_rgb_vectorized, test_optimize_embedding_oklab, test_get_target_hull_oklab)
  • Visual comparison of LAB vs OKLAB output on sample images

🤖 Generated with Claude Code

OKLab provides superior perceptual uniformity compared to CIELAB, where
Euclidean distance directly corresponds to perceived color difference.
This enables more accurate color mapping for dimensionality reduction.

Changes:
- Add generate_oklab_grid() and oklab_to_rgb_vectorized() to ucie.py
- Add OKLAB as a target for optimize_embedding()
- Add assign_colours_oklab() function to core.py
- Add OKLAB to CLI colormap choices and default 3D colormap list
- Export assign_colours_oklab in package __init__.py
- Add comprehensive tests for all new OKLab functionality

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@adamjtaylor adamjtaylor linked an issue Jan 13, 2026 that may be closed by this pull request
@claude
Copy link
Copy Markdown

claude Bot commented Jan 13, 2026


Code review

No issues found. Checked for bugs and CLAUDE.md compliance.


@adamjtaylor adamjtaylor merged commit fe0e4ba into main Jan 13, 2026
2 checks passed
@adamjtaylor adamjtaylor deleted the 30-oklab-colorspace branch January 13, 2026 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement OKLab colorspace

1 participant