Method: Magick::Image#distortion_channel
- Defined in:
- ext/RMagick/rmimage.cpp
#distortion_channel(reconstructed_image, metric, channel = Magick::AllChannels) ⇒ Float #distortion_channel(reconstructed_image, metric, *channels) ⇒ Float
Compares one or more image channels of an image to a reconstructed image and returns the specified distortion metric.
6011 6012 6013 6014 6015 6016 6017 6018 6019 6020 6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 6037 6038 6039 6040 6041 6042 6043 6044 6045 6046 6047 6048 6049 6050 6051 6052 6053 6054 6055 6056 6057 |
# File 'ext/RMagick/rmimage.cpp', line 6011
VALUE
Image_distortion_channel(int argc, VALUE *argv, VALUE self)
{
Image *image, *reconstruct;
ChannelType channels;
ExceptionInfo *exception;
MetricType metric;
VALUE rec;
double distortion;
#if defined(IMAGEMAGICK_7)
Image *difference_image;
#endif
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);
}
rec = rm_cur_image(argv[0]);
reconstruct = rm_check_destroyed(rec);
VALUE_TO_ENUM(argv[1], metric, MetricType);
exception = AcquireExceptionInfo();
#if defined(IMAGEMAGICK_7)
BEGIN_CHANNEL_MASK(image, channels);
GVL_STRUCT_TYPE(CompareImages) args = { image, reconstruct, metric, &distortion, exception };
difference_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(CompareImages), &args);
END_CHANNEL_MASK(image);
DestroyImage(difference_image);
#else
GVL_STRUCT_TYPE(GetImageChannelDistortion) args = { image, reconstruct, channels, metric, &distortion, exception };
CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GetImageChannelDistortion), &args);
#endif
CHECK_EXCEPTION();
DestroyExceptionInfo(exception);
RB_GC_GUARD(rec);
return rb_float_new(distortion);
}
|