Method: Magick::Image#channel

Defined in:
ext/RMagick/rmimage.c

#channel(channel_arg) ⇒ Object

Extract a channel from the image. A channel is a particular color component of each pixel in the image.

Ruby usage:

- @verbatim Image#channel @endverbatim

Parameters:

  • self

    this object

  • channel_arg

    the type of the channel to extract

Returns:

  • the channel of the specified type

[View source]

2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
# File 'ext/RMagick/rmimage.c', line 2151

VALUE
Image_channel(VALUE self, VALUE channel_arg)
{
    Image *image, *new_image;
    ChannelType channel;

    image = rm_check_destroyed(self);

    VALUE_TO_ENUM(channel_arg, channel, ChannelType);

    new_image = rm_clone_image(image);

    (void) SeparateImageChannel(new_image, channel);

    rm_check_image_exception(new_image, DestroyOnError);
    rm_ensure_result(new_image);

    return rm_image_new(new_image);
}