Method: Magick::Image#difference
- Defined in:
- ext/RMagick/rmimage.cpp
#difference(other) ⇒ Array<Float>
Compares two images and computes statistics about their difference.
5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 |
# File 'ext/RMagick/rmimage.cpp', line 5539
VALUE
Image_difference(VALUE self, VALUE other)
{
Image *image;
Image *image2;
VALUE mean, nmean, nmax;
#if defined(IMAGEMAGICK_7)
double distortion;
ExceptionInfo *exception;
#endif
image = rm_check_destroyed(self);
other = rm_cur_image(other);
image2 = rm_check_destroyed(other);
#if defined(IMAGEMAGICK_7)
exception = AcquireExceptionInfo();
GVL_STRUCT_TYPE(GetImageDistortion) args = { image, image2, MeanErrorPerPixelErrorMetric, &distortion, exception };
CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GetImageDistortion), &args);
CHECK_EXCEPTION();
DestroyExceptionInfo(exception);
#else
GVL_STRUCT_TYPE(IsImagesEqual) args = { image, image2 };
CALL_FUNC_WITHOUT_GVL(GVL_FUNC(IsImagesEqual), &args);
rm_check_image_exception(image, RetainOnError);
#endif
mean = rb_float_new(image->error.mean_error_per_pixel);
nmean = rb_float_new(image->error.normalized_mean_error);
nmax = rb_float_new(image->error.normalized_maximum_error);
RB_GC_GUARD(mean);
RB_GC_GUARD(nmean);
RB_GC_GUARD(nmax);
return rb_ary_new3(3, mean, nmean, nmax);
}
|