Method: Magick::Image#channel_extrema
- Defined in:
- ext/RMagick/rmimage.cpp
#channel_extrema(channel = Magick::AllChannels) ⇒ Array<Integer> #channel_extrema(*channels) ⇒ Array<Integer>
Returns the minimum and maximum intensity values for the specified channel or channels.
2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 |
# File 'ext/RMagick/rmimage.cpp', line 2495
VALUE
Image_channel_extrema(int argc, VALUE *argv, VALUE self)
{
Image *image;
ChannelType channels;
ExceptionInfo *exception;
size_t min, max;
VALUE ary;
image = rm_check_destroyed(self);
channels = extract_channels(&argc, argv);
// Ensure all arguments consumed.
if (argc > 0)
{
raise_ChannelType_error(argv[argc-1]);
}
exception = AcquireExceptionInfo();
#if defined(IMAGEMAGICK_7)
BEGIN_CHANNEL_MASK(image, channels);
GVL_STRUCT_TYPE(GetImageExtrema) args = { image, &min, &max, exception };
CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GetImageExtrema), &args);
END_CHANNEL_MASK(image);
#else
GVL_STRUCT_TYPE(GetImageChannelExtrema) args = { image, channels, &min, &max, exception };
CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GetImageChannelExtrema), &args);
#endif
CHECK_EXCEPTION();
DestroyExceptionInfo(exception);
ary = rb_ary_new2(2);
rb_ary_store(ary, 0, ULONG2NUM(min));
rb_ary_store(ary, 1, ULONG2NUM(max));
RB_GC_GUARD(ary);
return ary;
}
|