color-channels

command module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 29, 2022 License: GPL-3.0 Imports: 16 Imported by: 0

README

Color Channels

Go Reference Go Report Card

Color Channels is a simple, command-line program that can

  1. separate a color image into multiple grayscale images, each representing a single color channel, and
  2. combine multiple grayscale images, each representing a single color channel, into a unified color image.

Features

Color Channels supports the following color spaces:

An alpha (opacity) channel is supported for all of the above.

The user can specify an explicit white point for HCL, L*a*b*, and L*u*v* conversions.

The program accepts images provided in PNG, JPEG, GIF, or any of the Netpbm formats.

Unrepresentable colors are clamped gracefully to representable colors.

Installation

Color Channels is written in the Go programming language so you will need to install Go to compile it.

Once Go is installed, Color Channels can be downloaded, built, and installed into $GOPATH/bin/ simply by running

go install github.com/spakin/color-channels@latest

An alternative install location can be specified by first setting the GOBIN environment variable (e.g., export GOBIN=/usr/local/bin).

Usage

Basic operation

Run color-channels --help for a usage summary. In short, one of --split or --merge must be specified. For example,

color-channels --split --space=HCL -o channel-%s.png input-image.jpg

reads input-image.jpg and generates channel-H.png, representing the hue channel, channel-C.png, representing the chroma channel, and channel-L.png, representing the luminance channel. Output images always are written in PNG regardless of the input-image's format.

The channel images from the preceding command can be recombined (typically after transforming them in some manner) using --merge:

color-channels --merge --space=HCL -o output-image.png channel-H.png channel-C.png channel-L.png
A more concrete example

Here's a sample image, courtesy of https://file-examples.com/:

input-image

We can split the above into luma (gamma-corrected luminance), blue-difference, and red-difference channels with

color-channels --split --space="Y'CbCr" -o channel-%s.png example.jpg

channel-Y channel-Cb channel-Cr

Let's swap the blue-difference and red-difference channels when recombining the above to see what happens:

color-channels --merge --space="Y'CbCr" -o output-image.png channel-Y.png channel-Cr.png channel-Cb.png 

output-image

Color spaces

The --space option allows color-space names to include arbitrary punctuation and capitalization. That is, --space="L*a*b*" and --space=lab are treated identically.

Appending an A to any color-space name includes an alpha channel (named alpha on output).

Advanced usage

As a more advanced example, a white point can be specified via its x and y chromaticity coordinates. color-channels currently honors the white point for only a few color spaces, though. The default white point is D65. As an example, the F2 standard illuminant (cool white fluorescent) with a 2° standard observer can be requested with --white="0.37208 0.37529".

Author

Scott Pakin, scott+clrch@pakin.org

Documentation

Overview

color-channels splits an image into separate color channels and merges color channels into a new image.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL