#color-space #image #rgb #hsl #lab #graphics #luv

nightly app image-decompose

Decomposes image into separate channels in different colour spaces

4 releases (2 breaking)

0.4.1 May 21, 2021
0.4.0 May 15, 2021
0.3.0 May 14, 2021
0.1.0 May 13, 2021

#23 in #lab

GPL-3.0-or-later

1MB
719 lines

image-decompose

The tool decomposes an RGB image into it’s channels in different colour spaces. sRGB (including linear RGB), HSL, HSV, HBW, XYZ, xyY, L*a*b*, LChab, L*u*v*, LCHuv, CMY and CMYK models are supported.

For each of those the program will load input image as an sRGB image, convert it to given colour space and then create an image which includes coordinates

Example

An example image is included in data directory which can be used to test the program:

cargo run -- -y --resize 300x400 --crop 150x300+75+50 \
             -o out data/umbrella-sky.jpg

As a result, the tool generates handful of WebP images and saves them in the out directory with names matching umbrella-sky-*.webp pattern. Each of the image includes decomposition of the source image into separate channels in given colour space.

For example:

sRGB

An photo with its decomposition into red, green and blue channels

Perhaps the most familiar decomposition showing how much red, green and blue is in each pixel of the image. RGB model is additive thus the result comes from adding all those colours.

HSL

An photo with its decomposition into hue, saturaiton and lightens channels of HSL model

HSL attempts to be more user friendly by introducing more natural hue, saturation and lightness controls. The model isn’t perceptually uniform though so changing only hue affects luminosity of the colour.

Black spots in the hue channel indicates grey colours (which includes white and black) in the source images for which hue is undefined.

L*u*v* and LChuv

An photo with its decomposition into L*, u* and v* channels

An photo with its decomposition into L*, C* and hue channels of LCh(uv) model

L*u*v* colour space tries to be perceptually uniform. The decomposition demonstrates the L* channel corresponds to luminosity while u* and v* coordinates fall on the green-red and blue-yellow axes.

The L*C*h model makes the model easier to interpret by representing chromaticity with more familiar hue and chroma values.

CMY and CMYK

An photo with its decomposition into cyan, magenta and yellow channels

An photo with its decomposition into cyan, magenta, yellow and black channels

CMY and CMYK colour models are subtractive. This is demonstrated by the channels being ‘inverses’ of the image. The less red the image has, the more cyan is used and the same for green-magenta and blue-yellow pairs. The inverse is especially apparent with black (or key) channel in CMYK model.

Dependencies

~17MB
~220K SLoC