Colour

Colour#

Colour images as a stack of channel planes. A basis acts on one plane; the tasks and the step trainer take the stack (C, H, W) and keep one coefficient budget over all of it. A ColorSpace is the invertible change of channels applied at every pixel that makes the stack from an (..., H, W, C) image and puts it back: YCBCR, the luma and chroma differences of JPEG and video, or klt(), the principal axes of a dataset’s pixel colours.

Colour images as a stack of channel planes, and the colour space that makes the stack.

A basis acts on one (2**m, 2**n) plane. The tasks (pdft.tasks) and the step trainer take a stack of planes, (C, H, W), run the same basis on every plane and keep one coefficient budget over all of them, so colour enters as a change of channels: an invertible C x C matrix applied at every pixel, which takes an image laid out (..., H, W, C), as image files are read, to its planes (..., C, H, W) and back.

The matrix is what carries the gain. R, G and B of a photograph move together, and a budget shared across the planes of a decorrelated space sends the chroma planes few coefficients. Two spaces are provided: YCBCR, the luma and two chroma differences of JPEG and video (BT.601), and klt, the principal axes of a dataset’s pixel colours, which is orthonormal, so the error in its coefficients is the error in RGB. JPEG also halves the chroma resolution before its transform; under a coefficient budget that costs quality, so nothing here does it. ColorSpace(np.eye(3)) keeps RGB.

Contents

ColorSpace

An invertible change of channels, applied pixel by pixel.

YCBCR

An invertible change of channels, applied pixel by pixel.

klt

The principal axes of the pixel colours of images ((..., H, W, C)), largest variance first.