Method: Magick::Image#clut_channel
- Defined in:
- ext/RMagick/rmimage.cpp
#clut_channel(clut_image, channel = Magick::AllChannels) ⇒ Magick::Image #clut_channel(clut_image, *channels) ⇒ Magick::Image
Replace the channel values in the target image with a lookup of its replacement value in an LUT gradient image.
The LUT image should be either a single row or column image of replacement colors. The lookup is controlled by the -interpolate setting, especially for an LUT which is not the full length needed by the IM installed Quality (Q) level. Good settings for this is the default ‘bilinear’ or ‘bicubic’ interpolation setting for a smooth color gradient, or ‘integer’ for a direct unsmoothed lookup of color values.
This method is especially suited to replacing a grayscale image with specific color gradient from the CLUT image.
2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 |
# File 'ext/RMagick/rmimage.cpp', line 2772
VALUE
Image_clut_channel(int argc, VALUE *argv, VALUE self)
{
Image *image, *clut;
ChannelType channels;
MagickBooleanType okay;
#if defined(IMAGEMAGICK_7)
ExceptionInfo *exception;
#endif
image = rm_check_frozen(self);
// check_destroyed before confirming the arguments
if (argc >= 1)
{
clut = rm_check_destroyed(rm_cur_image(argv[0]));
channels = extract_channels(&argc, argv);
if (argc != 1)
{
rb_raise(rb_eArgError, "wrong number of arguments (%d for 1 or more)", argc);
}
}
else
{
rb_raise(rb_eArgError, "wrong number of arguments (%d for 1 or more)", argc);
}
#if defined(IMAGEMAGICK_7)
exception = AcquireExceptionInfo();
BEGIN_CHANNEL_MASK(image, channels);
GVL_STRUCT_TYPE(ClutImage) args = { image, clut, image->interpolate, exception };
void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ClutImage), &args);
okay = static_cast<MagickBooleanType>(reinterpret_cast<intptr_t &>(ret));
END_CHANNEL_MASK(image);
CHECK_EXCEPTION();
DestroyExceptionInfo(exception);
#else
GVL_STRUCT_TYPE(ClutImageChannel) args = { image, channels, clut };
void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ClutImageChannel), &args);
okay = static_cast<MagickBooleanType>(reinterpret_cast<intptr_t &>(ret));
rm_check_image_exception(image, RetainOnError);
rm_check_image_exception(clut, RetainOnError);
#endif
if (!okay)
{
rb_raise(rb_eRuntimeError, "ClutImageChannel failed.");
}
return self;
}
|