Skip to content

Commit d94981e

Browse files
Add index.md copy of README for GitHub Pages rendering
1 parent 7aefce3 commit d94981e

1 file changed

Lines changed: 355 additions & 0 deletions

File tree

index.md

Lines changed: 355 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,355 @@
1+
# Reference and Usage Guide
2+
**Version:** 1.1
3+
**Author:** Knut Larsson
4+
**Purpose:** Generate a calibration target image from ArgyllCMS `.cht` and `.cie` pairs, preserving colorimetric values and physical dimensions for printing or soft-proofing.
5+
6+
___
7+
8+
## Table of Contents
9+
10+
1. [Overview](#overview)
11+
2. [Supported Targets](#supported-targets)
12+
3. [Installation](#installation)
13+
4. [Command-Line Usage](#command-line-usage)
14+
5. [Arguments](#arguments)
15+
6. [Examples](#examples)
16+
7. [Use Cases](#use-cases)
17+
8. [ICC Profile Management](#icc-profile-management)
18+
9. [Features](#features)
19+
10. [Provided cht Files](#provided-cht-files)
20+
11. [Troubleshooting](#troubleshooting)
21+
12. [Technical Reference](#technical-reference)
22+
- [Scaling Model](#scaling-model)
23+
- [Fiducial Marks](#fiducial-marks)
24+
- [Chart Definition](#chart-definition)
25+
- [Patch Area Definitions](#patch-area-definitions)
26+
- [Color Conversion](#color-conversion)
27+
- [Labels and Text](#labels-and-text)
28+
- [Output](#output)
29+
- [Diagnostics](#diagnostics)
30+
13. [Notes](#notes)
31+
32+
___
33+
34+
## Overview
35+
36+
`rectarg.py` recreates calibration target images from `.cht` (chart layout) and `.cie` (reference data) files compatible with **ArgyllCMS**. It performs full color conversions (LAB → XYZ (D50) → sRGB (D65 via Bradford)), preserves physical dimensions, and adds fiducials, labels, and geometry for accurate reproduction.
37+
38+
Calibration targets ensure scanners, printers, and displays show colors consistently. Vendors often withhold digital originals; this tool reconstructs them faithfully for visual or colorimetric comparison.
39+
40+
### Applications
41+
42+
- **Display calibration:** Compare a display’s color calibration to the physical target.
43+
- **Printer calibration:** Print a clean target image for visual or colorimetric comparison.
44+
- **Scanner profiling:** Compare a scanned target against a reference image.
45+
46+
For example targets, see:
47+
- [Wolf Faust IT8 targets (12641-1)](http://www.targets.coloraid.de)
48+
- [LaserSoft Advanced IT8 target (12641-2)](https://www.silverfast.com/products-overview-products-company-lasersoft-imaging/it8-targets-for-scanner-calibration-profiling-for-predictable-brilliant-colors/)
49+
50+
ArgyllCMS (http://argyllcms.com) is a professional open-source color management system widely used for calibration workflows.
51+
52+
___
53+
54+
## Supported Targets
55+
56+
Tested successfully with:
57+
58+
- Wolf Faust IT8.7/2 Targets (12641-1)
59+
- LaserSoft Advanced Color Calibration Target IT8 (12641-2)
60+
- CMP Digital Target-4
61+
- Hutchcolor HCT
62+
- LaserSoft DCPro Studio Target
63+
- QPcard_202 Target
64+
- SpyderChecker & SpyderChecker24 Targets
65+
66+
> **Note:** There is a good chance rectarg may be used successfully on other cht-cie file pairs, but ColorChecker Passport is not supported due to unsupported `.cht` parameters.
67+
68+
___
69+
70+
## Installation
71+
72+
**Dependencies:**
73+
74+
```
75+
pip install numpy Pillow tifffile argparse scipy
76+
```
77+
78+
Required: `numpy`, `Pillow (PIL)`, `tifffile`, `argparse`
79+
Optional: `scipy`
80+
81+
___
82+
83+
## Command-Line Usage
84+
85+
```bash
86+
python3 rectarg.py <chart.cht> <data.cie> <output.tif> [options]
87+
```
88+
89+
### Example
90+
```bash
91+
python3 rectarg.py R230122W.cht R230122W.txt output.tif --target_dpi 300 --background GS10 --intent display --label_axis_visible X=B
92+
```
93+
94+
___
95+
96+
## Arguments
97+
98+
| Type | Argument | Description |
99+
|------|-----------|-------------|
100+
| Positional | `<chart.cht>` | Chart definition file (ArgyllCMS `.cht`) |
101+
| Positional | `<data.cie>` | Reference or measurement data (`.cie`, `.txt`, or `IT8`) |
102+
| Positional | `<output.tif>` | Output filename (16-bit TIFF) |
103+
| Optional | `--target_dpi [DPI]` | Output resolution (default: A4-fit scaled to 300 DPI) |
104+
| Optional | `--background-color [PATCH_ID]` | Use specified patch color as background |
105+
| Optional | `--intent [absolute;display]` | Color conversion intent. <br>`absolute` : Calibration reference / technical validation Keeps exact colorimetric data. Linear sRGB, 16-bit TIFF. D50→D65 adaptation only (no gamma), no perceptual modification.<br>`display` (default): Screen visualization / preview image added gamma 2.2 encoding (nonlinear tone mapping), 16-bit TIFF with gamma. |
106+
| Optional | `--color_space [lab;xyz]` | Input color space (default: lab) |
107+
| Optional | `--label_axis_visible [AREA_NAME]=[L;T;R;B;ALL;NONE]` | Manually toggle label sides. Left, Top, Right, Bottom, ALL (default), NONE. Can be specified multiple times. <br>Example: `--label_axis_visible X=B --label_axis_visible Y=RT` Forces only bottom label for area X, as well as right and top labels for area Y. |
108+
| Optional | `--margin [MM]` | Page margin in millimeters (default: 15) |
109+
| Optional | `--font [PATH]` | TrueType font path. If not found, the script searches common system font paths (Palatino, Helvetica, Times, Arial, DejaVuSans) |
110+
| Optional | `--font_mm [LABEL_MM] [FOOTER_MM]` | Physical text heights (default: 2 mm) |
111+
| Optional | `--png` | Save PNG preview |
112+
| Optional | `--debug` | Enable diagnostic output |
113+
114+
___
115+
116+
## Examples
117+
118+
For simplicity, open a terminal and go to a folder of choice. Place this script as well as `.cht` and `.cie` file in the folder. Run command as shown below.
119+
120+
```bash
121+
# Wolf Faust IT8.7/2 target for display
122+
python3 rectarg.py R230122W.cht R230122W.txt output.tif --target_dpi 300 --background GS10 --label_axis_visible X=B
123+
124+
# Wolf Faust IT8.7/2 target with custom font and text size (in mm)
125+
python3 rectarg.py R230122W.cht R230122W.txt output_font.tif --font /usr/share/fonts/truetype/dejavu/DejaVuSans.ttf --font_mm 3.0 2.0
126+
127+
# LaserSoft IT8 target, Absolute Colorimetric
128+
python3 rectarg.py ISO12641_2_1.cht R250715.cie output.tif --intent absolute --background-color N33 --target_dpi 200
129+
130+
# Hutchcolor HCT (XYZ data) for display
131+
python3 rectarg.py Hutchcolor.cht 0579.txt Hutchcolor.tif --target_dpi 200 --color_space xyz
132+
133+
# CMP Digital Target-4 for display
134+
python3 rectarg.py CMP_Digital_Target-4.cht CMP_Digital_Target-4.cie output.tif --target_dpi 200 --color_space xyz --label_axis_visible Y=TLB --label_axis_visible X=TRB --font_mm 1.5 1.5
135+
136+
# LaserSoft DCPro Studio Target for display
137+
python3 rectarg.py LaserSoftDCPro.cht D120104.txt LaserSoftDCPro-200dpi.tif --target_dpi 200 --intent absolute --font_mm 1 1 --margin 7
138+
139+
# QPcard_202 Target, Absolute Colorimetric
140+
python3 rectarg.py QPcard_202.cht QPcard_202.cie output.tif --intent absolute --target_dpi 200 --font_mm 2.5 2.5
141+
142+
# SpyderChecker Target, Absolute Colorimetric
143+
python3 rectarg.py SpyderChecker.cht SpyderChecker.cie SpyderChecker-200dpi.tif --intent absolute --target_dpi 200 --color_space xyz
144+
145+
# SpyderChecker24 for display
146+
python3 rectarg.py SpyderChecker24.cht SpyderChecker24.cie SpyderChecker24-200dpi.tif --target_dpi 200 --color_space xyz
147+
```
148+
149+
___
150+
151+
## Use Cases
152+
### General
153+
* Use the absolute intent image as colorimetric truth for numerical or colorimetric comparison only, e.g., when measuring Lab values. Image is too dark for printing or comparison against physical reference target.
154+
* Use the display intent image as visually faithful representation → for visual side-by-side comparison with the physical target or softproofing.
155+
156+
### Example Use Cases
157+
1. If you want to produce a printable target that looks like the physical chart (for visual comparison) you can do the following:
158+
159+
- Option 1: Use rectarg display intent image directly. Print it with color management ON (normal sRGB → printer conversion through your calibrated printer profile). That should yield a print that perceptually matches the physical target, for comparison against original physical reference target.
160+
161+
- Option 2: Comparison of Printed Image against Soft-Proofing Image Create a soft-proofing image for on-screen comparison against a printed target. Use display-intent image from rectarg and apply a printer's ICC profile via an application to create the soft-proofing image.
162+
163+
2. If you want to compare a scanned image of the reference target on-screen against created image from rectarg: Use rectarg display intent image directly. Compare against scanned image on-screen, assuming scanner uses calibrated icc/icm profile. If scanner output is raw, without any profile, then apply a scanner profile onto scanned image before comparing against rectarg display intent image.
164+
165+
3. If you want to compare a calibrated display against physical reference target: Use the rectarg display intent image directly on the display with color management enabled (ON). Then compare against physical target.
166+
167+
4. If you want to profile printer: Use rectarg display intent image and print without color management (OFF). Then scan/measure printed image and create icc-profile. If hand scanner is used, scale the image to maximize chart size when printing, if possible.
168+
169+
170+
### Overview of Use Cases
171+
172+
| Use Case | Image Intent | Tagged As | ICC Conversion | Color Management | Purpose |
173+
|-----------|---------------|------------|----------------|------------------|----------|
174+
| Display measurement | absolute | linear sRGB | No | ON (monitor ICC) | Numeric accuracy |
175+
| Display visual check | display | sRGB (γ2.2) | No | ON | Visual comparison |
176+
| Printer visual comparison | display | sRGB (γ2.2) | Yes <br>(soft-proofing) | ON | Match physical chart visually |
177+
| Printer profiling | display | sRGB (γ2.2) || OFF | Build printer profile |
178+
| Scanner profiling |||| OFF | Build/verify scanner profile |
179+
| Scanner visual comparison | display | sRGB (γ2.2) | No | ON | Visual compare scan vs target |
180+
| Scanner numeric comparison | absolute | linear sRGB | No | ON | Compare measured Lab vs reference |
181+
182+
### Intent Notes
183+
184+
- **Absolute intent:** Colorimetric truth for numerical analysis. Too dark for printing.
185+
- **Display intent:** Visually faithful representation for on-screen comparison.
186+
187+
___
188+
189+
## ICC Profile Management
190+
191+
Assigning or converting ICC profiles can, for example, be done using:
192+
- ArgyllCMS
193+
- ImageMagick
194+
- Photoshop
195+
- GIMP
196+
- macOS ColorSync Utility
197+
198+
### Example Commands
199+
200+
**ImageMagick:**
201+
```bash
202+
magick rectarg_image_display.tif -profile printer.icc rectarg_image_printproof.tif
203+
```
204+
205+
**ArgyllCMS:**
206+
```bash
207+
cctiff -i p -v printer.icm rectarg_image_display.tif rectarg_image_printproof.tif
208+
```
209+
210+
___
211+
212+
## Features
213+
214+
- Parses `.cht` layout definitions (fiducials, patch areas)
215+
- Reads `.cie`, `.txt`, or IT8 reference data
216+
- LAB → XYZ (D50) → sRGB (D65 via Bradford) color conversion
217+
- 16-bit RGB TIFF output
218+
- Automatic patch ID generation and labeling
219+
- DPI-scaled fiducials and text
220+
- Optional PNG preview
221+
- Margin and font customization
222+
223+
___
224+
225+
## Provided cht Files
226+
227+
Most targets tested with this script were provided with the ArgyllCMS software, and many of those have probably been made manually, as several had odd configurations and dummy data, which caused bad images by rectarg.
228+
229+
For the purpose of generating nice looking images I have edited the definition part of several of the `.cht` files. Those who want to experiment with getting an exact match of fiducials to original target may modify the `.cht` file, or use those provided for a nice printout.
230+
231+
Details on how to interpret the specification inside the `.cht` file are provided below.
232+
233+
___
234+
235+
## Troubleshooting
236+
237+
* If individual gray patches appear instead of colors: Related Patch ID cannot be found in `.cie` file.
238+
* If all patches come out as gray:
239+
- Selection of color space is wrong. If `.cie` file does not contain columns related to selected color space, try other color space with flag `--color_space [lab;xyz]`.
240+
- `Patch Area` line (ex. `Y`) in `.cht` layout definitions has label definitions that cannot be found in `.cie` file.
241+
- Patch Labels cannot be found in `.cie` file.
242+
* If fiducial marks are positioned wrong:
243+
- `F` line in `.cht` layout definitions has wrong coordinate numbers.
244+
245+
___
246+
247+
## Technical Reference
248+
249+
### Scaling Model
250+
251+
- `.cht` coordinates used directly; rescaled to chosen DPI.
252+
- Physical proportions are preserved for A4-fit DPIs (72, 100, 200, 300, 600, 1200).
253+
254+
Example:
255+
256+
If 100dpi is detected, scaling factor is calculated in reference to 300 DPI:
257+
- scale_x ≈ 2.9988 px/unit
258+
- scale_y ≈ 3.0009 px/unit
259+
- Each 25.625 unit patch (at 100dpi) becomes ≈ 77×77 px (≈ 6.52 mm per side)
260+
261+
### Fiducial Marks
262+
263+
- Defined by `F` lines in `.cht`.
264+
- L-shaped corners; DPI-scaled size and thickness (≈ 5 px at 300 DPI).
265+
266+
### Chart Definition
267+
268+
- Defined by `D` line in `.cht`.
269+
- `D` line defines overall chart dimensions.
270+
- Not used by rectarg.
271+
272+
Example:
273+
```
274+
D ALL ALL _ _ 613 433 49.0 33.0 0 0
275+
```
276+
277+
### Patch Area Definitions
278+
279+
- Defined by `Y` and `X` lines in `.cht`.
280+
- `Y` defines main color patch grid.
281+
- `X` defines secondary grid area.
282+
- Naming should be unique per patch area.
283+
284+
Example (Wolf Faust Target):
285+
```
286+
Y 01 22 A L 25.625 25.625 26.625 26.625 25.625 25.625
287+
X GS00 GS23 _ _ 25.625 51.25 1.0 360.5 25.625 0
288+
```
289+
290+
Interpreted as:
291+
[xstart, xend, ystart, yend, tile_x, tile_y, pre_x, pre_y, post_x, post_y]
292+
293+
- Labels:
294+
- Numeric [xstart, xend]: 01–22 → “01”…“22”
295+
- Alphabetic [ystart, yend]: A–L → “A”…“L”
296+
- Prefixed [xstart, xend]: GS00–GS23 → “GS00”…“GS23”
297+
- “_” disables labels for that axis
298+
- Each patch ID (e.g. A01) is matched to corresponding data in `.cie`.
299+
- Supports recognition of label differences, such as A1 vs A01, or with or without quotes (A1 vs "A1"), or special labels with preceding number, like "2A1".
300+
- Supports two letter running alphabetical labels, like A-AX → “A”…“AX”.
301+
302+
- Grid defining coordinates:
303+
- [tile_x, tile_y]: Pixel units (at a given dpi defined by originator) for color patch.
304+
- [pre_x, pre_y]: Chart area padding. Pixel units from reference (0,0) where first patch is placed.
305+
- [post_x, post_y]: Chart area padding. Pixel units added in x direction after last column for the specified patch grid area, and added in y direction after last row placement.
306+
307+
308+
### Color Conversion
309+
310+
- Default data columns from cie file: LAB
311+
- Alternatively, data columns can be selected to use XYZ columns.
312+
- Conversion chain: LAB (D50) → XYZ (D50) → XYZ (D65 via Bradford) → sRGB (IEC 61966-2-1)
313+
- Resulting RGB values are not clipped or manipulated to preserve true reference colors.
314+
315+
### Labels and Text
316+
317+
- Footer includes: creation date, originator, descriptor, and manufacturer.
318+
- Patch IDs automatically generated from label start/end tokens
319+
- Top and left patch labels, plus mirrored labels on bottom and right sides
320+
- Physical sizing in mm maintained via pixel scaling. Example: 2.0 mm → 24 px at 300 DPI.
321+
- Hides labels if two patch areas are too close to each other.
322+
- Required clearance between defined patch areas is calculated dynamically, based on the maximum label size plus 2 mm buffer. That way:
323+
- Column labels appear only if there’s at least (font height + 2 mm) vertical gap. If column labels are rotated, rotated label’s longest dimension is used instead of font height.
324+
- Row labels appear only if there’s at least (max label width + 2 mm) horizontal gap.
325+
- Footer block includes:
326+
- 'CREATED' date (if available)
327+
- Data file name
328+
- Center text: “Reproduction of Target from reference data”
329+
- 'ORIGINATOR', 'DESCRIPTOR', and 'MANUFACTURER' fields (right-aligned)
330+
- Some files converted by ArgyllCMS tools to cie type may use very different defining parameter names for the above. To get the info displayed correctly with rectarg you should rename the appropriate parameter according names mentioned above. Those are based on parameters used in Wolf Faust IT8.7/2 Target
331+
332+
333+
334+
### Output
335+
336+
- Default: 16-bit TIFF with embedded DPI.
337+
- Optional PNG preview (`--png`).
338+
339+
### Diagnostics
340+
341+
**Normal mode:** Summary only.
342+
**Debug mode:** Detailed info on scaling, geometry, patch mapping, and colors.
343+
344+
___
345+
346+
## Notes
347+
348+
- Compatible with Wolf Faust, LaserSoft, Hutchcolor, and similar targets.
349+
- Handles LAB/RGB field naming differences.
350+
- Maintains geometry, margins, and fiducials.
351+
- Ideal for calibration, visualization, and reference reprints.
352+
353+
___
354+
355+
**End of README**

0 commit comments

Comments
 (0)