Skip to content

HMath.Image.Color

Module index · Numerical conventions

Description

Three-channel color conversion. sRGB uses the IEC piecewise transfer; XYZ is D65 with Y=1 for reference white; Lab uses that same D65 white (no implicit chromatic adaptation). Hue is in turns [0,1), HSV/HSL saturation and brightness/lightness in [0,1]. Full-range BT.601 YCbCr uses chroma offset 0.5. Out-of-gamut conversions return finite unclipped values; converting those results back requires the target color space's input domain. Matrix and Lab definitions: https://www.w3.org/TR/css-color-4/ .

On this page

API Purpose
ColorSpace Color coordinate convention,including sRGB,linear RGB,HSV,HSL,XYZ,Lab,and YCbCr. convertColor validates each source convention's ranges.
SRGB Declaration and type contract below.
LinearRGB Declaration and type contract below.
HSV Declaration and type contract below.
HSL Declaration and type contract below.
XYZ Declaration and type contract below.
Lab Declaration and type contract below.
YCbCr Declaration and type contract below.
convertColor Explicit source/destination spaces; three interleaved channels required.
grayscale Rec.709 luminance, explicitly converting the stated source to linear RGB.
srgbToLinear Transfer functions extend linearly below their positive breakpoints; finite negative/out-of-gamut channels are retained.
linearToSrgb Encode a finite linear-light channel with the sRGB piecewise transfer function (linear branch through 0.0031308).

Documentation

ColorSpace

data ColorSpace Source #

Color coordinate convention,including sRGB,linear RGB,HSV,HSL,XYZ,Lab,and YCbCr. convertColor validates each source convention's ranges.

Constructors

SRGB 
LinearRGB 
HSV 
HSL 
XYZ 
Lab 
YCbCr 

Instances

Instances details
Show ColorSpace Source # 
Instance details

Defined in HMath.Image.Color

Eq ColorSpace Source # 
Instance details

Defined in HMath.Image.Color

convertColor

convertColor :: ColorSpace -> ColorSpace -> Image -> Either MathError Image Source #

Explicit source/destination spaces; three interleaved channels required.

grayscale

grayscale :: ColorSpace -> Image -> Either MathError Image Source #

Rec.709 luminance, explicitly converting the stated source to linear RGB.

srgbToLinear

srgbToLinear :: Double -> Either MathError Double Source #

Transfer functions extend linearly below their positive breakpoints; finite negative/out-of-gamut channels are retained.

linearToSrgb

linearToSrgb :: Double -> Either MathError Double Source #

Encode a finite linear-light channel with the sRGB piecewise transfer function (linear branch through 0.0031308). No automatic clipping is performed. Non-finite input/result returns Left MathError.