1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
//! Professional color calibration and matching tools for `OxiMedia`.
//!
//! `oximedia-calibrate` provides comprehensive color calibration and matching
//! capabilities for professional video and image processing workflows. This includes:
//!
//! - **Camera Calibration**: `ColorChecker`-based camera profiling and characterization
//! - **Display Calibration**: Monitor calibration, gamma correction, and profiling
//! - **Color Matching**: Match colors across multiple cameras and devices
//! - **ICC Profile Generation**: Create ICC color profiles from measurements
//! - **ICC Profile Application**: Apply ICC profiles to images and video
//! - **LUT Generation**: Generate calibration LUTs from measurements
//! - **White Balance**: Advanced white balance algorithms and presets
//! - **Color Temperature**: Automatic color temperature detection and shifting
//! - **Gamut Mapping**: Map device gamut to working color space
//! - **Chromatic Adaptation**: Adapt colors to different illuminants
//!
//! # Example
//!
//! ```rust,ignore
//! use oximedia_calibrate::{
//! camera::{ColorChecker, ColorCheckerType},
//! white::WhiteBalancePreset,
//! temp::estimate_color_temperature,
//! };
//!
//! # fn example() -> Result<(), Box<dyn std::error::Error>> {
//! // Detect ColorChecker in an image
//! let checker = ColorChecker::detect_in_image(&image_data, ColorCheckerType::Classic24)?;
//!
//! // Generate camera profile
//! let profile = checker.generate_camera_profile()?;
//!
//! // Apply white balance
//! let balanced = WhiteBalancePreset::Daylight.apply_to_image(&image_data)?;
//!
//! // Estimate color temperature
//! let temp = estimate_color_temperature(&image_data)?;
//! # Ok(())
//! # }
//! ```
//!
//! # Features
//!
//! ## Camera Calibration
//!
//! - Automatic `ColorChecker` detection in images
//! - Patch extraction with subpixel accuracy
//! - Camera profile generation (ICC/LUT)
//! - Multi-illuminant calibration support
//! - Calibration verification and validation
//!
//! ## Display Calibration
//!
//! - Gamma curve measurement and calibration
//! - Display uniformity testing
//! - Monitor profiling for accurate color reproduction
//! - Display characterization
//!
//! ## Color Matching
//!
//! - Multi-camera color matching workflows
//! - Scene-to-scene color matching for continuity
//! - Match to reference target capabilities
//! - Color consistency verification
//!
//! ## ICC Profiles
//!
//! - ICC v2 and v4 profile generation
//! - ICC profile parsing and validation
//! - ICC profile application to images
//! - Profile inspection and analysis
//!
//! ## LUT Generation
//!
//! - Measurement-based LUT creation
//! - 1D and 3D calibration LUTs
//! - LUT verification and validation
//! - Interpolation quality assessment
//!
//! ## White Balance
//!
//! - Automatic white balance from scene analysis
//! - Standard presets (Daylight, Tungsten, Fluorescent, etc.)
//! - Custom white balance from reference patch
//! - Gray world and white patch algorithms
//!
//! ## Color Temperature
//!
//! - Automatic color temperature estimation
//! - Temperature shift application
//! - Kelvin to RGB conversion
//! - Illuminant D-series support
//!
//! ## Gamut Mapping
//!
//! - Device gamut to working space mapping
//! - Perceptual gamut mapping strategies
//! - Gamut compression algorithms
//! - Out-of-gamut color handling
//!
//! ## Chromatic Adaptation
//!
//! - Bradford chromatic adaptation transform
//! - Von Kries adaptation
//! - CAT02 adaptation (CIECAM02)
//! - Custom illuminant adaptation
//!
//! # `ColorChecker` Support
//!
//! - X-Rite `ColorChecker` Classic (24 patches)
//! - X-Rite `ColorChecker` Passport
//! - `Datacolor` `SpyderCheckr`
//! - Custom target support
//!
//! # Calibration Workflows
//!
//! ## Camera Profiling Workflow
//!
//! 1. Shoot `ColorChecker` under target lighting
//! 2. Detect `ColorChecker` in image
//! 3. Extract patch colors
//! 4. Generate camera ICC profile or LUT
//! 5. Apply calibration to footage
//! 6. Verify calibration accuracy
//!
//! ## Display Calibration Workflow
//!
//! 1. Measure display with colorimeter
//! 2. Generate gamma and uniformity profiles
//! 3. Create display ICC profile
//! 4. Apply profile to output pipeline
//! 5. Verify display accuracy
//!
//! ## Camera Matching Workflow
//!
//! 1. Calibrate primary camera (Camera A)
//! 2. Shoot matching target with Camera B
//! 3. Generate matching LUT/profile
//! 4. Apply to Camera B footage
//! 5. Verify color matching across cameras
pub use ;
/// RGB color value (normalized to 0.0-1.0 range).
pub type Rgb = ;
/// RGBA color value (normalized to 0.0-1.0 range).
pub type Rgba = ;
/// XYZ tristimulus value.
pub type Xyz = ;
/// LAB color value (L*a*b* color space).
pub type Lab = ;
/// 3x3 color matrix.
pub type Matrix3x3 = ;
/// 3x4 color matrix with offset.
pub type Matrix3x4 = ;
/// Standard illuminant types.
/// Observer angle for colorimetric calculations.