Skip to content

Densiometry

densiometry

Here data and functions for handling and specifying density values is included.

Functions:

Attributes:

APD module-attribute

APD = np.asarray(
    colour.MultiSpectralDistributions(APD).align(SPECTRAL_SHAPE).values,
    dtype=DEFAULT_DTYPE,
)

ACES printing density.

DENSIOMETRY module-attribute

DENSIOMETRY = {
    "status_a": STATUS_A,
    "status_m": STATUS_M,
    "apd": APD,
    "absolute": STATUS_A,
}

A dict with relevant density measures.

DENSITY_MEASURE module-attribute

DENSITY_MEASURE = Literal['status_a', 'status_m', 'apd', 'absolute', 'bw']

The available density measures.

STATUS_A module-attribute

STATUS_A = np.asarray(interpolate_status_density(STATUS_A))

Status A density measure.

STATUS_M module-attribute

STATUS_M = np.asarray(interpolate_status_density(STATUS_M))

Status M density measure.

adx16_decode

adx16_decode(
    adx: ndarray, apd_min: ndarray | None = None, scaling: float = 1.0
) -> ndarray

Converts from ADX16 values to absolute APD density. Instead of as 16 bit int the output is expected as a float in the range [0, 1].

Parameters:

  • adx

    (ndarray) –

    ADX16 values in the range [0, 1].

  • apd_min

    (ndarray | None, default: None ) –

    The D-min values of the film that has been compensated for.

  • scaling

    (float, default: 1.0 ) –

    Linear scaling removed from the values. For 1.0 it is ADX16-like and for 4.0 it is ADX10-like.

Returns:

  • ndarray –

    Absolute APD density values.

adx16_encode

adx16_encode(
    apd: ndarray, apd_min: ndarray | None = None, scaling: float = 1.0
) -> ndarray

Converts from absolute APD density values to ADX16 values. Instead of as 16 bit int, the output is encoded as a float in the range [0, 1].

Parameters:

  • apd

    (ndarray) –

    The density values.

  • apd_min

    (ndarray | None, default: None ) –

    The D-min values of the film to compensate for.

  • scaling

    (float, default: 1.0 ) –

    Linear scaling applied to the values. For 1.0 it is ADX16-like and for 4.0 it is ADX10-like.

Returns:

  • ndarray –

    ADX-like encoded values in the [0, 1] range.

compute_printer_lights

compute_printer_lights() -> tuple[ndarray, ndarray]

Converts the APD printer light to a three light matrix by splitting into separate red, green, and blue lights.

construct_spectral_density

construct_spectral_density(ref_density: SpectralDistribution, sigma=25) -> ndarray

Split single density curve into separate layers using local extrema.

interpolate_status_density

interpolate_status_density(
    status: list[dict[int, float]], spectral_shape=SPECTRAL_SHAPE
) -> ndarray

Converts logarithmic status density values to a normalized linear status density matrix.

output_to_density

output_to_density(
    y: ndarray,
    a: ndarray,
    b: ndarray,
    x0: ndarray | None = None,
    method: str = "lm",
) -> ndarray
Numerically invert the mapping

y = (10 ** -(x @ a.T)) @ b

to recover x.

Parameters

y : array-like, shape (p,) Output vector. a : array-like, shape (m, n) Density matrix (used in forward map). b : array-like, shape (m, p) Output matrix (used in forward map). x0 : array-like, shape (n,), optional Initial guess for x. Defaults to zeros. method : str, optional Least-squares solver method: 'lm', 'trf', or 'dogbox'.

Returns

x : ndarray, shape (n,) Estimated vector such that (10 ** -(x @ a.T)) @ b ≈ y

wavelength_argmax

wavelength_argmax(distribution: SpectralDistribution, low=None, high=None) -> int

Gets the argmax of a spectral distribution.

wavelength_argmin

wavelength_argmin(distribution: SpectralDistribution, low=None, high=None) -> int

Gets the argmax of a spectral distribution.