channelMap

Applies a transformation per-channel. expr may be in the form of a => ..., or (a, ref b) { b = ...; } (only if T is explicitly specified).

  1. auto channelMap(COLOR c)
    template channelMap(alias expr)
    channelMap
    (
    COLOR
    )
    (
    COLOR c
    )
    if (
    is(COLOR == struct) &&
    !is(expr == struct)
    )
    if (
    !is(expr == struct)
    )
  2. template channelMap(T, alias expr = a => a)

Members

Functions

channelMap
auto channelMap(COLOR c)
Undocumented in source. Be warned that the author may not have intended to support it.

Examples

// Effortlessly reordering channels with no modification.
assert(RGB(1, 2, 3).channelMap!BGR == BGR(3, 2, 1));

// Perform per-channel transformations.
assert(RGB(1, 2, 3).channelMap!(v => cast(ubyte)(v + 1)) == RGB(2, 3, 4));

// Perform per-channel transformations with a different resulting type, implicitly.
assert(RGB(1, 2, 3).channelMap!(v => cast(ushort)(v + 1)) == RGB16(2, 3, 4));

// Perform per-channel transformations with a different resulting type, explicitly.
assert(RGB(1, 2, 3).channelMap!(RGB16, v => cast(ubyte)(v + 1)) == RGB16(2, 3, 4));

// Ditto, with a ref parameter instead of return.
assert(RGB(1, 2, 3).channelMap!(RGB16, (a, ref b) { b = a; b++; }) == RGB16(2, 3, 4));

// Effortlessly convert an image
import ae.utils.graphics.image : Image, colorMap, copy;
Image!BGR i = Image!RGB().colorMap!(channelMap!BGR).copy();

Meta