Method: Magick::Image#separate

Defined in:
ext/RMagick/rmimage.cpp

#separate(channel = Magick::AllChannels) ⇒ Magick::ImageList #separate(*channels) ⇒ Magick::ImageList

Constructs a grayscale image for each channel specified.

Overloads:

  • #separate(channel = Magick::AllChannels) ⇒ Magick::ImageList

    Parameters:

    • channel (Magick::ChannelType) (defaults to: Magick::AllChannels)

      a ChannelType arguments.

  • #separate(*channels) ⇒ Magick::ImageList

    Parameters:

    • *channels (Magick::ChannelType)

      one or more ChannelType arguments.

Returns:



12694
12695
12696
12697
12698
12699
12700
12701
12702
12703
12704
12705
12706
12707
12708
12709
12710
12711
12712
12713
12714
12715
12716
12717
12718
12719
12720
12721
12722
12723
12724
12725
# File 'ext/RMagick/rmimage.cpp', line 12694

VALUE
Image_separate(int argc, VALUE *argv, VALUE self)
{
    Image *image, *new_images;
    ChannelType channels = UndefinedChannel;
    ExceptionInfo *exception;

    image = rm_check_destroyed(self);
    channels = extract_channels(&argc, argv);

    // All arguments are ChannelType enums
    if (argc > 0)
    {
        raise_ChannelType_error(argv[argc-1]);
    }

    exception = AcquireExceptionInfo();
#if defined(IMAGEMAGICK_7)
    BEGIN_CHANNEL_MASK(image, channels);
    GVL_STRUCT_TYPE(SeparateImages) args = { image, exception };
    new_images = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SeparateImages), &args);
    CHANGE_RESULT_CHANNEL_MASK(new_images);
    END_CHANNEL_MASK(image);
#else
    GVL_STRUCT_TYPE(SeparateImages) args = { image, channels, exception };
    new_images = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SeparateImages), &args);
#endif
    rm_check_exception(exception, new_images, DestroyOnError);
    DestroyExceptionInfo(exception);

    return rm_imagelist_from_images(new_images);
}