Method: Magick::Image#convolve_channel
- Defined in:
- ext/RMagick/rmimage.c
permalink #convolve_channel(*args) ⇒ Object
call ConvolveImageChannel.
Ruby usage:
- @verbatim Image#convolve_channel(order, kernel) @endverbatim
- @verbatim Image#convolve_channel(order, kernel, channel) @endverbatim
- @verbatim Image#convolve_channel(order, kernel, channel, ...) @endverbatim
4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 |
# File 'ext/RMagick/rmimage.c', line 4148
VALUE
Image_convolve_channel(int argc, VALUE *argv, VALUE self)
{
Image *image, *new_image;
double *kernel;
volatile VALUE ary;
unsigned int x, order;
ChannelType channels;
ExceptionInfo exception;
image = rm_check_destroyed(self);
channels = extract_channels(&argc, argv);
// There are 2 required arguments.
if (argc > 2)
{
raise_ChannelType_error(argv[argc-1]);
}
if (argc != 2)
{
rb_raise(rb_eArgError, "wrong number of arguments (%d for 2 or more)", argc);
}
order = NUM2UINT(argv[0]);
ary = argv[1];
rm_check_ary_len(ary, (long)(order*order));
kernel = ALLOC_N(double, (long)(order*order));
// Convert the kernel array argument to an array of doubles
for (x = 0; x < order*order; x++)
{
kernel[x] = NUM2DBL(rb_ary_entry(ary, (long)x));
}
GetExceptionInfo(&exception);
new_image = ConvolveImageChannel(image, channels, order, kernel, &exception);
xfree((void *)kernel);
rm_check_exception(&exception, new_image, DestroyOnError);
(void) DestroyExceptionInfo(&exception);
rm_ensure_result(new_image);
return rm_image_new(new_image);
}
|