ANSI and ISO Density¶
Density may be calculated from LabColor instances.
- colormath.density.auto_density(color)[source]¶
Given a SpectralColor, automatically choose the correct ANSI T filter. Returns a tuple with a string representation of the filter the calculated density.
Parameters: color (SpectralColor) – The SpectralColor object to calculate density for. Return type: float Returns: The density value, with the filter selected automatically.
- colormath.density.ansi_density(color, density_standard)[source]¶
Calculates density for the given SpectralColor using the spectral weighting function provided. For example, ANSI_STATUS_T_RED. These may be found in colormath.density_standards.
Parameters: - color (SpectralColor) – The SpectralColor object to calculate density for.
- std_array (numpy.ndarray) – NumPy array of filter of choice from colormath.density_standards.
Return type: float
Returns: The density value for the given color and density standard.
Example¶
from colormath.color_objects import SpectralColor
from colormath.density import auto_density, ansi_density
from colormath.density_standards import ANSI_STATUS_T_RED
# Omitted the full spectral kwargs for brevity.
color = SpectralColor(spec_340nm=0.08, ...)
# ANSI T Density for the spectral color.
density = auto_density(color)
# Or maybe we want to specify which filter to use.
red_density = ansi_density(color, ANSI_STATUS_T_RED)
Valid Density Constants¶
The following density constants within colormath.density_standards can be passed to colormath.density.ansi_density():
- ANSI_STATUS_A_RED
- ANSI_STATUS_A_GREEN
- ANSI_STATUS_A_BLUE
- ANSI_STATUS_E_RED
- ANSI_STATUS_E_GREEN
- ANSI_STATUS_E_BLUE
- ANSI_STATUS_M_RED
- ANSI_STATUS_M_GREEN
- ANSI_STATUS_M_BLUE
- ANSI_STATUS_T_RED
- ANSI_STATUS_T_GREEN
- ANSI_STATUS_T_BLUE
- TYPE1
- TYPE2
- ISO_VISUAL