hydrax.image#

Provides colorspace-aware utilities for loading and processing images with Pillow (PIL).

The primary entry-point to this module is open_srgb().

Tip

You can ensure this module has its dependencies by installing hydrax with the “image” extra via pip install hydrax[image,...].

CONVERT_PERCEPTUAL

Perceptual colorspace conversion intent with HIGHRESPRECALC.

CONVERT_RELATIVE

Relative colorimetric colorspace conversion intent with HIGHRESPRECALC and BLACKPOINTCOMPENSATION.

Coefs

Dtype-agnostic coefficients for image representation and colorspace conversion.

convert_balanced_to_frac_chw

Converts an image data array in balanced [-scale, scale] HWC format to a fractional [0.0, 1.0] representation in-place.

convert_balanced_to_frac_hwc

Converts an image data array in balanced [-scale, scale] HWC format to a fractional [0.0, 1.0] representation in-place.

convert_frac_to_balanced_chw

Converts an image data array in fractional [0.0, 1.0] CHW format to a balanced [-scale, scale] representation in-place.

convert_frac_to_balanced_hwc

Converts an image data array in fractional [0.0, 1.0] HWC format to a balanced [-scale, scale] representation in-place.

convert_oklab_to_srgb_frac_chw

Converts an image data array in fractional [0.0, 1.0] CHW format from Oklab to sRGB in-place.

convert_oklab_to_srgb_frac_hwc

Converts an image data array in fractional [0.0, 1.0] HWC format from Oklab to sRGB in-place.

convert_srgb_to_oklab_frac_chw

Converts an image data array in fractional [0.0, 1.0] CHW format from sRGB to Oklab in-place.

convert_srgb_to_oklab_frac_hwc

Converts an image data array in fractional [0.0, 1.0] HWC format from sRGB to Oklab in-place.

from_srgb_hwc

Creates a PIL image from sRGB image data in the HWC format, using the specified coefficients for byte conversion.

open_srgb

Opens an image using PIL and ensures it is in the sRGB colorspace.

set_max_image_pixels

Sets the PIL decompression bomb threshold.

write_chw

Writes a PIL image or HWC image data array to the specified NumPy array with shape CHW.

write_hwc

Writes a PIL image or HWC image data array to the specified NumPy array with shape HWC.