CrImage::Util::Channels
Channel operations for extracting, manipulating, and combining color channels.
Provides methods for working with individual R, G, B, A channels as grayscale images, useful for advanced image processing and compositing workflows.
Class methods
Combines separate channel images into an RGBA image.
Parameters:
red: Red channel (Gray image)green: Green channel (Gray image)blue: Blue channel (Gray image)alpha: Alpha channel (Gray image, optional - defaults to opaque)
Returns: Combined RGBA image
Raises: ArgumentError if channel dimensions don't match
Extracts a single channel from an image as a grayscale image.
Parameters:
src: Source imagechannel: Channel to extract (:red, :green, :blue, :alpha)
Returns: Gray image containing the channel values
Inverts a specific channel.
Parameters:
src: Source imagechannel: Channel to invert (:red, :green, :blue, :alpha)
Returns: New RGBA image with inverted channel
Applies a function to a specific channel.
Parameters:
src: Source imagechannel: Channel to modify (:red, :green, :blue, :alpha)&block: Function that takes channel value (0-255) and returns new value
Returns: New RGBA image with modified channel
Multiplies a channel by a factor.
Parameters:
src: Source imagechannel: Channel to multiply (:red, :green, :blue, :alpha)factor: Multiplication factor (0.0 to any positive value)
Returns: New RGBA image with scaled channel
Sets a channel to a constant value.
Parameters:
src: Source imagechannel: Channel to set (:red, :green, :blue, :alpha)value: Value to set (0-255)
Returns: New RGBA image with constant channel
Splits an image into its R, G, B channels.
Parameters:
src: Source image
Returns: Tuple of (red, green, blue) Gray images
Splits an image into its R, G, B, A channels.
Parameters:
src: Source image
Returns: Tuple of (red, green, blue, alpha) Gray images
Swaps two channels in an image.
Parameters:
src: Source imagech1: First channel (:red, :green, :blue)ch2: Second channel (:red, :green, :blue)
Returns: New RGBA image with swapped channels