# LithiumCMS [![License: AGPL v3](https://img.shields.io/badge/License-AGPL_v3-blue.svg)](LICENSE) [![Language: C](https://img.shields.io/badge/Language-C-brightgreen.svg)](Argyll_V3.5.0/) [![Platform](https://img.shields.io/badge/Platform-Linux%20%7C%20macOS%20%7C%20Windows-lightgrey.svg)]() [![ICC Specification](https://img.shields.io/badge/ICC-v2.1%20%2F%20v4.4-orange.svg)](https://www.color.org/) **LithiumCMS** is a high-performance color management engine and ICC profile generator. Designed for precision prepress, digital printing, and display calibration, LithiumCMS combines mathematical color modeling with spectral measurement processing to construct accurate International Color Consortium (ICC) device profiles. In addition to standard RGB, CMY, and CMYK printing, LithiumCMS provides native **multichannel (5- to 7-color) Expanded Color Gamut (ECG)** profiling (such as CMYK+OG, CMYK+OGV, and CcMmYK), featuring numerical optimization-based BtoA CLUT inversion, dynamic ink limits, and automatic colorant table generation. --- ## Key Features - **High-Precision Profile Generation:** Generates ICC v2.1 and v4.4 device profiles with high-resolution forward (`AtoB`) and reverse (`BtoA`) multi-dimensional lookup tables (CLUTs). - **Native Multichannel (5–7 Color) Profiling:** Full end-to-end support for 5CLR (`CMYKO`), 6CLR (`CMYKOG`), and 7CLR (`CMYKOGV`) printing workflows, embedding mandatory ICC Colorant Table (`clrt`) tags with named colorants and Lab coordinates. - **Constrained Optimization BtoA Inversion:** Advanced numerical inversion engine (`mchan_inv.c`) powered by the Powell non-linear optimizer, bypassing the 4-dimensional simplicial geometry cap (`MXRI=4`) of classical reverse spline solvers. - **Adaptive CLUT Geometry & Dynamic TAC:** Adaptive grid sizing for high-dimensional device spaces to maintain memory efficiency, paired with dynamic Total Area Coverage (TAC) scaling up to $N \times 100\%$. - **Regular Simplex Splines (RSPL):** Mathematical multi-dimensional scattered data interpolation engine supporting up to 10 input/output dimensions. - **Adaptive Inking & Separation:** Advanced TAC enforcement, Gray Component Replacement (GCR), and custom black generation curves. - **Hardware Instrument Support:** Direct integration with industry-standard spectrophotometers and colorimeters (X-Rite, Barbieri, Datacolor, Konica Minolta). - **Gamut Mapping & Verification:** Colorimetric, Perceptual, and Saturation rendering intents with CIECAM02 viewing condition modeling and rigorous $\Delta E$ round-trip verification. --- ## Multichannel & Expanded Gamut (ECG) Roadmap LithiumCMS natively supports high-fidelity 5, 6, and 7-color presses: | Device Space | Channels | Status | Description | | :--- | :---: | :---: | :--- | | **Gray** | 1 | **Stable** | Monochrome reflective / emissive devices | | **RGB / CMY** | 3 | **Stable** | Standard displays, scanners, and 3-component digital presses | | **CMYK** | 4 | **Stable** | Commercial 4-color offset and digital printing | | **5CLR** | 5 | **Verified** | CMYK + 1 supplemental ink (e.g., Orange, White, or Red) — avg $\Delta E = 2.38$ | | **6CLR** | 6 | **Verified** | Hexachrome, CMYK+OG, or CcMmYK (Light Cyan/Magenta) — avg $\Delta E = 1.90$ | | **7CLR** | 7 | **Verified** | Expanded Color Gamut / Fogra55 standard (**CMYKOGV**) — avg $\Delta E = 2.15$ | > [!NOTE] > Implementation details, numerical stability fixes, and empirical round-trip verification benchmarks are documented in [**`MULTICHANNEL_IMPLEMENTATION_PLAN.md`**](MULTICHANNEL_IMPLEMENTATION_PLAN.md). Foundational research and mathematical analyses are documented in [**`MULTICHANNEL_EXPANSION_RESEARCH_AND_PLAN.md`**](MULTICHANNEL_EXPANSION_RESEARCH_AND_PLAN.md). --- ## Profiling Pipeline & CLI Utilities LithiumCMS provides a modular command-line toolchain covering every stage of characterization and profiling: ```mermaid flowchart LR A["targen
(Patch Generator)"] -->|test.ti1| B["printtarg
(PostScript/TIFF Layout)"] B -->|Print & Measure| C["chartread
(Spectrophotometer)"] C -->|test.ti3| D["colprof
(Profile Engine)"] D -->|profile.icc| E["xicclu / profcheck
(Gamut & Verification)"] ``` ### Core Utilities | Binary | Role | Description | | :--- | :--- | :--- | | `targen` | Target Generation | Generates scattered, multidimensional, or body-centered cubic test patches in device space. | | `printtarg` | Layout Engine | Converts `.ti1` patch lists into printable PostScript, EPS, TIFF, or PDF target charts. | | `chartread` | Measurement | Drives connected spectrophotometers (i1Pro, etc.) to capture spectral / CIELAB reflection data into `.ti3` files. | | `colprof` | Profile Generator | Reads measured `.ti3` data and compiles the forward and inverse CLUTs into an ICC device profile. | | `xicclu` | Profile Lookup | Evaluates profiles in forward or reverse directions for color conversions, ink values, and diagnostics. | | `profcheck` | Accuracy Verification | Computes average, maximum, and percentile $\Delta E$ report against characterization datasets. | ### Quick Start: Basic Printer Profile (CMYK) ```bash # 1. Generate an optimized CMYK test chart with 836 patches and 64 gray ramp steps bin/targen -v -d4 -f836 -g64 my_printer # 2. Format into a 300 DPI TIFF target ready to print without color management bin/printtarg -v -ii1 -pA4 -T300 my_printer # 3. Measure target with a spectrophotometer (e.g. i1Pro) to create my_printer.ti3 bin/chartread -v -y1 -N my_printer # 4. Generate the ICC profile with high quality and 280% total ink limit (TAC) bin/colprof -v -qm -t280 -D "Custom Press Profile" my_printer # 5. Inspect and verify profile accuracy bin/profcheck -v -k my_printer.ti3 my_printer.icc ``` ### Quick Start: Multichannel ECG Profile (CMYKOGV 7-Color) ```bash # 1. Generate an expanded gamut test target (preset -d11 targets CMYKOGV) bin/targen -v -d11 -f500 -g32 test_7clr # 2. Build the ICC profile (automatically enables adaptive CLUTs and Powell BtoA inversion) bin/colprof -v -qm -D "Test CMYKOGV 7-Color Profile" test_7clr # 3. Verify profile header, clrt colorants, and Lut16 CLUT dimensions bin/iccdump test_7clr.icc # 4. Run automated round-trip accuracy verification (Forward -> Inversion -> Round-Trip dE) python3 Argyll_V3.5.0/test_multichannel/verify_roundtrip.py test_7clr.icc ``` --- ## Building from Source LithiumCMS uses Perforce Jam (`jam` / `ftjam`) for multi-platform compilation. ### 1. Prerequisites #### Debian / Ubuntu / Mint ```bash sudo apt update sudo apt install build-essential ftjam libtiff-dev libjpeg-dev libpng-dev libusb-1.0-0-dev libx11-dev libxext-dev libxinerama-dev libxrandr-dev libxxf86vm-dev ``` #### Fedora / RHEL ```bash sudo dnf install gcc gcc-c++ jam libtiff-devel libjpeg-turbo-devel libpng-devel libusb1-devel libX11-devel libXext-devel libXinerama-devel libXrandr-devel ``` #### macOS (Homebrew) ```bash brew install jam libtiff libpng jpeg-turbo libusb ``` --- ### 2. Native Compilation From the repository root: ```bash cd Argyll_V3.5.0 jam -q -fJambase ``` Upon completion, compiled executables reside in their corresponding module directories (e.g., `profile/colprof`, `icc/iccdump`, `xicc/xicclu`, `target/targen`). To install system-wide (optional): ```bash sudo ./makeinstall.sh ``` --- ### 3. Containerized Build (Docker) For a clean, reproducible build environment without modifying host packages: ```dockerfile # Save as Dockerfile.build FROM ubuntu:24.04 RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential ftjam libtiff-dev libjpeg-dev libpng-dev \ libusb-1.0-0-dev libx11-dev libxext-dev libxinerama-dev \ libxrandr-dev libxxf86vm-dev ca-certificates git \ && rm -rf /var/lib/apt/lists/* WORKDIR /build COPY . . WORKDIR /build/Argyll_V3.5.0 RUN jam -q -fJambase CMD ["/bin/bash"] ``` Build and run: ```bash docker build -t lithium-cms:latest -f Dockerfile.build . docker run --rm -it -v $(pwd):/workspace lithium-cms:latest ``` --- ## Codebase Organization ```text LithiumCMS/ ├── README.md # Project documentation ├── MULTICHANNEL_IMPLEMENTATION_PLAN.md # Implementation specs, bugfixes & verification benchmarks ├── MULTICHANNEL_EXPANSION_RESEARCH_AND_PLAN.md # Foundational research and architectural blueprint └── Argyll_V3.5.0/ # Core engine source tree ├── Jamfile, Jambase, Jamtop # Perforce Jam build scripts ├── icc/ # Core ICC profile parser and tag structures (icclib) ├── rspl/ # Regular Simplex Spline forward and inverse engine ├── profile/ # Profile generation logic (colprof, profout, profin) ├── xicc/ # Extended color transforms, colorants, inking & mchan_inv ├── gamut/ # 3D surface description and gamut mapping ├── target/ # Test chart patch generators (targen, printtarg) ├── cgats/ # CGATS / IT8 text measurement file parser (.ti1, .ti3) ├── spectro/ # Hardware spectrophotometer communication drivers ├── numlib/ # Numerical analysis, matrix math, non-linear optimizers └── test_multichannel/ # Synthetic test targets (5-7ch) & verification suite ``` --- ## Technical Documentation & References - [Multichannel Implementation Plan & Verification Benchmarks](MULTICHANNEL_IMPLEMENTATION_PLAN.md): Technical specifications of the dynamic input pipeline, adaptive CLUT resolutions, Powell-based inversion, runtime stability fixes, and round-trip verification results. - [Multichannel Research & Technical Blueprint](MULTICHANNEL_EXPANSION_RESEARCH_AND_PLAN.md): In-depth architectural analysis of the forward and reverse CLUT bottlenecks, simplicial inversion limits, and mathematical models for expanded color gamut printing. - [ICC.1 Specification (ICC v4)](https://www.color.org/icc_specs2.xalter): International Color Consortium Profile Format. - [FOGRA55 Characterization Data](https://fogra.org/en/downloads/work-tools/fogra55-ecg): Standard exchange dataset for 7-color Expanded Color Gamut (CMYKOGV) printing. --- ## Licensing & Acknowledgments - **License:** LithiumCMS is published under the **GNU Affero General Public License Version 3 (AGPLv3)**. See [License.txt](Argyll_V3.5.0/License.txt) for details. - **Attribution:** LithiumCMS builds upon the foundational architecture, mathematical modeling, and device driver implementations of **ArgyllCMS**, originally authored and maintained by **Graeme W. Gill**.