or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

chromatic-adaptation.mdcolor-appearance-models.mdcolor-conversions.mdcolor-diff.mdcolor-objects.mdconstants-standards.mdindex.mdspectral-density.md

spectral-density.mddocs/

0

# Spectral Color and Density

1

2

Spectral color and density functionality provides comprehensive support for working with spectral power distributions and calculating color densities using industry standards. This is essential for applications in printing, color reproduction, and spectroscopic analysis.

3

4

## Capabilities

5

6

### Automatic Density Calculation

7

8

Automatically determine the best density standard and calculate density for a spectral color.

9

10

```python { .api }

11

def auto_density(color):

12

"""

13

Automatically calculate density for spectral color.

14

15

Parameters:

16

- color: SpectralColor object with wavelength data

17

18

Returns:

19

float: Calculated density value

20

21

Notes:

22

- Automatically selects appropriate density standard

23

- Uses visual density threshold for standard selection

24

- Optimized for typical printing and reproduction applications

25

"""

26

```

27

28

### ANSI Density Calculation

29

30

Calculate density using specific ANSI density standards for precise control over measurement conditions.

31

32

```python { .api }

33

def ansi_density(color, density_standard):

34

"""

35

Calculate density with specific ANSI standard.

36

37

Parameters:

38

- color: SpectralColor object with wavelength data

39

- density_standard: Density standard dictionary (from density_standards module)

40

41

Returns:

42

float: Calculated density value using specified standard

43

44

Notes:

45

- Provides precise control over density measurement

46

- Supports all ANSI status standards (T, A, E, M)

47

- Essential for color reproduction and printing applications

48

"""

49

```

50

51

## Spectral Color Usage

52

53

### Creating Spectral Colors

54

55

Spectral colors represent full spectral power distributions from 340nm to 830nm in 10nm intervals.

56

57

```python

58

from colormath.color_objects import SpectralColor

59

60

# Create spectral color with wavelength data

61

spectral = SpectralColor(

62

spec_400nm=0.064, # 400nm

63

spec_410nm=0.065, # 410nm

64

spec_420nm=0.066, # 420nm

65

spec_430nm=0.067, # 430nm

66

spec_440nm=0.068, # 440nm

67

spec_450nm=0.069, # 450nm

68

# Continue for all wavelengths...

69

spec_680nm=0.102, # 680nm

70

spec_690nm=0.105, # 690nm

71

spec_700nm=0.108, # 700nm

72

observer='2',

73

illuminant='d65'

74

)

75

```

76

77

### Spectral Color Methods

78

79

```python

80

from colormath.color_objects import SpectralColor

81

82

# Create spectral color

83

spectral = SpectralColor(

84

spec_400nm=0.064,

85

spec_410nm=0.065,

86

# ... more wavelength data

87

spec_700nm=0.108

88

)

89

90

# Calculate density using built-in method

91

density = spectral.calc_density()

92

93

# Convert to NumPy array for analysis

94

import numpy as np

95

spectral_array = spectral.get_numpy_array()

96

97

# Get wavelength values

98

wavelengths = np.arange(340, 840, 10) # 340-830nm in 10nm steps

99

```

100

101

## Density Standards

102

103

### ANSI Status T Standards

104

105

Status T standards for transmission density measurements.

106

107

```python

108

from colormath.density_standards import (

109

ANSI_STATUS_T_RED,

110

ANSI_STATUS_T_GREEN,

111

ANSI_STATUS_T_BLUE

112

)

113

from colormath.density import ansi_density

114

115

# Calculate density using Status T Red

116

density_red = ansi_density(spectral_color, ANSI_STATUS_T_RED)

117

density_green = ansi_density(spectral_color, ANSI_STATUS_T_GREEN)

118

density_blue = ansi_density(spectral_color, ANSI_STATUS_T_BLUE)

119

```

120

121

### ANSI Status A Standards

122

123

Status A standards for reflection density measurements.

124

125

```python

126

from colormath.density_standards import (

127

ANSI_STATUS_A_RED,

128

ANSI_STATUS_A_GREEN,

129

ANSI_STATUS_A_BLUE

130

)

131

from colormath.density import ansi_density

132

133

# Calculate reflection densities

134

density_a_red = ansi_density(spectral_color, ANSI_STATUS_A_RED)

135

density_a_green = ansi_density(spectral_color, ANSI_STATUS_A_GREEN)

136

density_a_blue = ansi_density(spectral_color, ANSI_STATUS_A_BLUE)

137

```

138

139

### ANSI Status E Standards

140

141

Status E standards for photographic applications.

142

143

```python

144

from colormath.density_standards import (

145

ANSI_STATUS_E_RED,

146

ANSI_STATUS_E_GREEN,

147

ANSI_STATUS_E_BLUE

148

)

149

```

150

151

### ANSI Status M Standards

152

153

Status M standards for motion picture applications.

154

155

```python

156

from colormath.density_standards import (

157

ANSI_STATUS_M_RED,

158

ANSI_STATUS_M_GREEN,

159

ANSI_STATUS_M_BLUE

160

)

161

```

162

163

### ISO Visual Standard

164

165

ISO visual density standard for visual assessment.

166

167

```python

168

from colormath.density_standards import ISO_VISUAL, VISUAL_DENSITY_THRESH

169

from colormath.density import ansi_density, auto_density

170

171

# Use ISO visual standard

172

density_visual = ansi_density(spectral_color, ISO_VISUAL)

173

174

# Visual density threshold for automatic selection

175

threshold = VISUAL_DENSITY_THRESH

176

```

177

178

## Usage Examples

179

180

### Complete Spectral Analysis Workflow

181

182

```python

183

from colormath.color_objects import SpectralColor, XYZColor

184

from colormath.color_conversions import convert_color

185

from colormath.density import auto_density, ansi_density

186

from colormath.density_standards import ANSI_STATUS_T_RED

187

188

# Create spectral color from measurement data

189

spectral_data = {

190

'spec_400nm': 0.064, 'spec_410nm': 0.065, 'spec_420nm': 0.066,

191

'spec_430nm': 0.067, 'spec_440nm': 0.068, 'spec_450nm': 0.069,

192

'spec_460nm': 0.070, 'spec_470nm': 0.071, 'spec_480nm': 0.072,

193

'spec_490nm': 0.073, 'spec_500nm': 0.074, 'spec_510nm': 0.075,

194

'spec_520nm': 0.076, 'spec_530nm': 0.077, 'spec_540nm': 0.078,

195

'spec_550nm': 0.079, 'spec_560nm': 0.080, 'spec_570nm': 0.081,

196

'spec_580nm': 0.082, 'spec_590nm': 0.083, 'spec_600nm': 0.084,

197

'spec_610nm': 0.085, 'spec_620nm': 0.086, 'spec_630nm': 0.087,

198

'spec_640nm': 0.088, 'spec_650nm': 0.089, 'spec_660nm': 0.090,

199

'spec_670nm': 0.091, 'spec_680nm': 0.092, 'spec_690nm': 0.093,

200

'spec_700nm': 0.094

201

}

202

203

spectral = SpectralColor(observer='2', illuminant='d50', **spectral_data)

204

205

# Calculate densities

206

auto_dens = auto_density(spectral)

207

ansi_dens = ansi_density(spectral, ANSI_STATUS_T_RED)

208

209

# Convert to tristimulus values

210

xyz = convert_color(spectral, XYZColor)

211

212

print(f"Auto density: {auto_dens:.3f}")

213

print(f"ANSI T Red density: {ansi_dens:.3f}")

214

print(f"XYZ: X={xyz.xyz_x:.3f}, Y={xyz.xyz_y:.3f}, Z={xyz.xyz_z:.3f}")

215

```

216

217

### Printing Quality Control

218

219

```python

220

from colormath.color_objects import SpectralColor

221

from colormath.density import ansi_density

222

from colormath.density_standards import (

223

ANSI_STATUS_T_RED, ANSI_STATUS_T_GREEN, ANSI_STATUS_T_BLUE

224

)

225

226

def analyze_print_density(spectral_measurements):

227

"""

228

Analyze print density for CMYK quality control.

229

230

Parameters:

231

- spectral_measurements: List of SpectralColor objects

232

233

Returns:

234

dict: Density analysis results

235

"""

236

results = []

237

238

for i, spectral in enumerate(spectral_measurements):

239

density_red = ansi_density(spectral, ANSI_STATUS_T_RED)

240

density_green = ansi_density(spectral, ANSI_STATUS_T_GREEN)

241

density_blue = ansi_density(spectral, ANSI_STATUS_T_BLUE)

242

243

results.append({

244

'patch': i + 1,

245

'red_density': density_red,

246

'green_density': density_green,

247

'blue_density': density_blue,

248

'max_density': max(density_red, density_green, density_blue)

249

})

250

251

return results

252

253

# Example usage with multiple spectral measurements

254

spectral_patches = [spectral1, spectral2, spectral3] # List of SpectralColor objects

255

density_analysis = analyze_print_density(spectral_patches)

256

257

for result in density_analysis:

258

print(f"Patch {result['patch']}: Max density = {result['max_density']:.3f}")

259

```

260

261

### Spectroscopic Data Processing

262

263

```python

264

import numpy as np

265

from colormath.color_objects import SpectralColor

266

267

def create_spectral_from_array(wavelengths, reflectances, observer='2', illuminant='d65'):

268

"""

269

Create SpectralColor from wavelength and reflectance arrays.

270

271

Parameters:

272

- wavelengths: Array of wavelengths (nm)

273

- reflectances: Array of reflectance values

274

- observer: Observer angle

275

- illuminant: Illuminant specification

276

277

Returns:

278

SpectralColor object

279

"""

280

# Interpolate to standard 10nm intervals from 340-830nm

281

standard_wavelengths = np.arange(340, 840, 10)

282

interpolated_reflectances = np.interp(standard_wavelengths, wavelengths, reflectances)

283

284

# Create spectral data dictionary

285

spectral_data = {}

286

for wl, refl in zip(standard_wavelengths, interpolated_reflectances):

287

spectral_data[f'spec_{wl}nm'] = refl

288

289

return SpectralColor(observer=observer, illuminant=illuminant, **spectral_data)

290

291

# Example usage

292

measured_wavelengths = np.array([380, 400, 420, 440, 460, 480, 500, 520, 540, 560, 580, 600, 620, 640, 660, 680, 700, 720])

293

measured_reflectances = np.array([0.05, 0.06, 0.07, 0.08, 0.09, 0.10, 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.20, 0.21, 0.22])

294

295

spectral_color = create_spectral_from_array(measured_wavelengths, measured_reflectances)

296

density = auto_density(spectral_color)

297

```

298

299

### Multi-Standard Density Comparison

300

301

```python

302

from colormath.density_standards import *

303

from colormath.density import ansi_density

304

305

def compare_density_standards(spectral_color):

306

"""

307

Compare density calculations across different standards.

308

309

Parameters:

310

- spectral_color: SpectralColor object

311

312

Returns:

313

dict: Density values for different standards

314

"""

315

standards = {

316

'Status T Red': ANSI_STATUS_T_RED,

317

'Status T Green': ANSI_STATUS_T_GREEN,

318

'Status T Blue': ANSI_STATUS_T_BLUE,

319

'Status A Red': ANSI_STATUS_A_RED,

320

'Status A Green': ANSI_STATUS_A_GREEN,

321

'Status A Blue': ANSI_STATUS_A_BLUE,

322

'ISO Visual': ISO_VISUAL

323

}

324

325

results = {}

326

for name, standard in standards.items():

327

try:

328

density = ansi_density(spectral_color, standard)

329

results[name] = density

330

except Exception as e:

331

results[name] = f"Error: {e}"

332

333

return results

334

335

# Example usage

336

density_comparison = compare_density_standards(spectral_color)

337

for standard, density in density_comparison.items():

338

print(f"{standard}: {density}")

339

```

340

341

## Density Applications

342

343

### Print Industry

344

- **Process control**: Monitor ink density consistency

345

- **Quality assurance**: Verify print density standards

346

- **Color matching**: Ensure consistent reproduction

347

348

### Photography

349

- **Film analysis**: Measure photographic density

350

- **Print evaluation**: Assess print quality

351

- **Calibration**: Standardize density measurements

352

353

### Spectroscopy

354

- **Material analysis**: Characterize material properties

355

- **Color research**: Study color appearance

356

- **Instrument calibration**: Validate measurement systems

357

358

## Technical Notes

359

360

### Wavelength Coverage

361

- **Standard range**: 340-830nm in 10nm intervals

362

- **Total points**: 50 wavelength measurements

363

- **Interpolation**: Automatic for non-standard intervals

364

365

### Density Standards Structure

366

Each density standard contains:

367

- **Wavelength data**: Spectral response curves

368

- **Weighting factors**: Standard-specific calculations

369

- **Normalization**: Industry-standard scaling

370

371

### Performance Considerations

372

- **Memory usage**: Spectral data requires more memory than tristimulus

373

- **Calculation speed**: Density calculations involve integration over wavelength

374

- **Precision**: Full spectral data provides highest accuracy