Class: Magick::KernelInfo
- Inherits:
-
Object
- Object
- Magick::KernelInfo
- Defined in:
- ext/RMagick/rmmain.c
Class Method Summary collapse
-
.builtin(what, geometry) ⇒ Magick::KernelInfo
Create new instance of KernelInfo with one of the ‘named’ built-in types of kernels used for special purposes such as gaussian blurring, skeleton pruning, and edge distance determination.
Instance Method Summary collapse
-
#clone ⇒ Magick::KernelInfo
Creates a new clone of the object so that its can be modified without effecting the original.
-
#dup ⇒ Magick::KernelInfo
Creates a new clone of the object so that its can be modified without effecting the original.
-
#initialize(kernel_string) ⇒ Magick::KernelInfo
constructor
KernelInfo object constructor.
-
#scale(scale, flags) ⇒ Object
Scales the given kernel list by the given amount, with or without normalization of the sum of the kernel values (as per given flags).
-
#scale_geometry(geometry) ⇒ Object
Takes a geometry argument string, typically provided as a -set option:convolve:scale {geometry} user setting, and modifies the kernel according to the parsed arguments of that setting.
-
#unity_add(scale) ⇒ Object
Adds a given amount of the ‘Unity’ Convolution Kernel to the given pre-scaled and normalized Kernel.
Constructor Details
#initialize(kernel_string) ⇒ Magick::KernelInfo
KernelInfo object constructor
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'ext/RMagick/rmkinfo.c', line 45
VALUE
KernelInfo_initialize(VALUE self, VALUE kernel_string)
{
KernelInfo *kernel;
#if defined(IMAGEMAGICK_7)
ExceptionInfo *exception;
#endif
Check_Type(kernel_string, T_STRING);
#if defined(IMAGEMAGICK_7)
exception = AcquireExceptionInfo();
kernel = AcquireKernelInfo(StringValueCStr(kernel_string), exception);
if (rm_should_raise_exception(exception, DestroyExceptionRetention))
{
if (kernel != (KernelInfo *) NULL)
{
DestroyKernelInfo(kernel);
}
rm_raise_exception(exception);
}
#else
kernel = AcquireKernelInfo(StringValueCStr(kernel_string));
#endif
if (!kernel)
{
rb_raise(rb_eRuntimeError, "failed to parse kernel string");
}
DATA_PTR(self) = kernel;
return self;
}
|
Class Method Details
.builtin(what, geometry) ⇒ Magick::KernelInfo
Create new instance of KernelInfo with one of the ‘named’ built-in types of kernels used for special purposes such as gaussian blurring, skeleton pruning, and edge distance determination.
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
# File 'ext/RMagick/rmkinfo.c', line 163
VALUE
KernelInfo_builtin(VALUE self, VALUE what, VALUE geometry)
{
KernelInfo *kernel;
KernelInfoType kernel_type;
GeometryInfo info;
#if defined(IMAGEMAGICK_7)
ExceptionInfo *exception;
#endif
Check_Type(geometry, T_STRING);
VALUE_TO_ENUM(what, kernel_type, KernelInfoType);
ParseGeometry(StringValueCStr(geometry), &info);
#if defined(IMAGEMAGICK_7)
exception = AcquireExceptionInfo();
kernel = AcquireKernelBuiltIn(kernel_type, &info, exception);
if (rm_should_raise_exception(exception, DestroyExceptionRetention))
{
if (kernel != (KernelInfo *) NULL)
{
DestroyKernelInfo(kernel);
}
rm_raise_exception(exception);
}
#else
kernel = AcquireKernelBuiltIn(kernel_type, &info);
#endif
if (!kernel)
{
rb_raise(rb_eRuntimeError, "failed to acquire builtin kernel");
}
return Data_Wrap_Struct(self, NULL, rm_kernel_info_destroy, kernel);
}
|
Instance Method Details
#clone ⇒ Magick::KernelInfo
Creates a new clone of the object so that its can be modified without effecting the original.
147 148 149 150 151 152 |
# File 'ext/RMagick/rmkinfo.c', line 147
VALUE
KernelInfo_clone(VALUE self)
{
KernelInfo *kernel = CloneKernelInfo((KernelInfo*)DATA_PTR(self));
return Data_Wrap_Struct(Class_KernelInfo, NULL, rm_kernel_info_destroy, kernel);
}
|
#dup ⇒ Magick::KernelInfo
Creates a new clone of the object so that its can be modified without effecting the original.
147 148 149 150 151 152 |
# File 'ext/RMagick/rmkinfo.c', line 147
VALUE
KernelInfo_clone(VALUE self)
{
KernelInfo *kernel = CloneKernelInfo((KernelInfo*)DATA_PTR(self));
return Data_Wrap_Struct(Class_KernelInfo, NULL, rm_kernel_info_destroy, kernel);
}
|
#scale(scale, flags) ⇒ Object
Scales the given kernel list by the given amount, with or without normalization of the sum of the kernel values (as per given flags).
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'ext/RMagick/rmkinfo.c', line 108
VALUE
KernelInfo_scale(VALUE self, VALUE scale, VALUE flags)
{
GeometryFlags geoflags;
if (!FIXNUM_P(scale))
Check_Type(scale, T_FLOAT);
if (rb_obj_is_instance_of(flags, Class_GeometryFlags))
VALUE_TO_ENUM(flags, geoflags, GeometryFlags);
else
rb_raise(rb_eArgError, "expected Integer or Magick::GeometryFlags to specify flags");
/* ScaleKernelInfo() was private function until IM 6.9 */
MagickExport void ScaleKernelInfo(KernelInfo *kernel, const double scaling_factor, const GeometryFlags normalize_flags);
ScaleKernelInfo((KernelInfo*)DATA_PTR(self), NUM2DBL(scale), geoflags);
return Qnil;
}
|
#scale_geometry(geometry) ⇒ Object
Takes a geometry argument string, typically provided as a -set option:convolve:scale {geometry} user setting, and modifies the kernel according to the parsed arguments of that setting.
134 135 136 137 138 139 140 |
# File 'ext/RMagick/rmkinfo.c', line 134
VALUE
KernelInfo_scale_geometry(VALUE self, VALUE geometry)
{
Check_Type(geometry, T_STRING);
ScaleGeometryKernelInfo((KernelInfo*)DATA_PTR(self), StringValueCStr(geometry));
return Qnil;
}
|
#unity_add(scale) ⇒ Object
Adds a given amount of the ‘Unity’ Convolution Kernel to the given pre-scaled and normalized Kernel.
86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'ext/RMagick/rmkinfo.c', line 86
VALUE
KernelInfo_unity_add(VALUE self, VALUE scale)
{
if (!FIXNUM_P(scale))
Check_Type(scale, T_FLOAT);
/* UnityAddKernelInfo() was private function until IM 6.9 */
MagickExport void UnityAddKernelInfo(KernelInfo *kernel, const double scale);
UnityAddKernelInfo((KernelInfo*)DATA_PTR(self), NUM2DBL(scale));
return Qnil;
}
|