Method: Magick::Image#channel_compare
- Defined in:
- ext/RMagick/rmimage.cpp
#compare_channel(image, metric, channel = Magick::AllChannels) ⇒ Array #compare_channel(image, metric, channel = Magick::AllChannels) {|opt_args| ... } ⇒ Array #compare_channel(image, metric, *channels) ⇒ Array #compare_channel(image, metric, *channels) {|opt_args| ... } ⇒ Array
Compare one or more channels in two images and returns the specified distortion metric and a comparison image.
3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 |
# File 'ext/RMagick/rmimage.cpp', line 3439 VALUE Image_compare_channel(int argc, VALUE *argv, VALUE self) { Image *image, *r_image, *difference_image; double distortion; VALUE ary, ref; MetricType metric_type; ChannelType channels; ExceptionInfo *exception; image = rm_check_destroyed(self); channels = extract_channels(&argc, argv); 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); } rm_get_optional_arguments(self); ref = rm_cur_image(argv[0]); r_image = rm_check_destroyed(ref); VALUE_TO_ENUM(argv[1], metric_type, MetricType); exception = AcquireExceptionInfo(); #if defined(IMAGEMAGICK_7) BEGIN_CHANNEL_MASK(image, channels); GVL_STRUCT_TYPE(CompareImages) args = { image, r_image, metric_type, &distortion, exception }; difference_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(CompareImages), &args); END_CHANNEL_MASK(image); #else GVL_STRUCT_TYPE(CompareImageChannels) args = { image, r_image, channels, metric_type, &distortion, exception }; difference_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(CompareImageChannels), &args); #endif rm_check_exception(exception, difference_image, DestroyOnError); DestroyExceptionInfo(exception); ary = rb_ary_new2(2); rb_ary_store(ary, 0, rm_image_new(difference_image)); rb_ary_store(ary, 1, rb_float_new(distortion)); RB_GC_GUARD(ary); RB_GC_GUARD(ref); return ary; } |