# CLAUDE.md This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. ## Project Overview Chrome is a high-performance C++17 port of negfix8, a tool for processing scanned color negative film. It inverts and color-corrects 16-bit linear Rec.709 TIFF images from film scanners. ## Build Commands ```bash # Configure and build cmake -B build/ -S . cd build && make # The executable is built at build/chrome ``` **Dependencies:** OpenCV (core, imgproc, imgcodecs), OpenMP (optional, for parallelization) ## Testing Manual testing only. Compare output against reference files in `test_data/`: - `test_data/test_input.tiff` - Sample input scan - `test_data/test_expected.tiff` - Reference output from original negfix8 - `test_data/current_output.tiff` - Current implementation output ```bash ./build/chrome -i test_data/test_input.tiff -o test_data/current_output.tiff # Then visually compare or diff against test_data/test_expected.tiff ``` ## Usage ```bash ./chrome -i input.tif [-o output.tif] [flags] Flags: -g Set gamma (default 2.15) -cs Enable contrast stretching -sat Enable saturation boost (+20%) -m Mirror image horizontally -r Binning (scale down by 1/N) -c Create profile and save to file (exits after) -u Use existing profile ``` ## Architecture Single-file implementation in `main.cpp` with this pipeline: 1. **Settings/Profile structs** - CLI options and image analysis data 2. **Image analysis** (`analyzeImage`) - Finds min/max per channel after shave+blur preprocessing 3. **Profile save/load** - Stores derived gamma corrections and offset values 4. **LUT generation** (`generateLUTs`) - Creates 65536-entry lookup tables for each channel using OpenMP 5. **Pixel processing** - Applies LUTs in parallel via OpenMP 6. **Post-processing** - Optional saturation boost, contrast stretch, mirror 7. **Output** - Writes LZW-compressed TIFF The core algorithm inverts negative film by dividing film base values by pixel values, applies per-channel gamma correction to neutralize orange mask, then applies global gamma.