ExtractChannel
Extracts a channel from a pixmap or a sound.
Syntax
-
ExtractChannel(pm, fam, ch)-
pmis a pixmap -
famis one of"rgb","hsv", and"hsl" -
chis one of the characters infam
-
-
ExtractChannel(snd, n)-
sndis a sound -
nis a non-negative integer
-
Description
If pm is a pixmap, then ExtractChannel(pm, fam, ch) returns the specified RGB, HSV, or HSL channel from pm as a greyscale pixmap.
If snd is a sound, then ExtractChannel(snd, n) returns the channel with index n in snd as a single-channel sound. Sound channels indices are zero-based, so the first channel has index 0.
Examples
S ≔ ExampleData("Sally");
pm ≔ CreatePixmap(width(S), (4/3)⋅height(S));
spm ≔ scale(S, 1/3);
pm ≔ DrawRect(pm, S, 0, 0);
for(i, 1, 3,
(
pm ≔ DrawRect(
pm,
ExtractChannel(spm, "rgb", characters("rgb")[i]),
width(spm)⋅(i − 1),
height(S))
)
);
pm
