Struct magick_rust::KernelInfo
source · pub struct KernelInfo { /* private fields */ }
Implementations§
source§impl KernelInfo
impl KernelInfo
sourcepub fn scale(&mut self, factor: f64)
pub fn scale(&mut self, factor: f64)
The values within the kernel is scaled directly using given scaling factor without change.
sourcepub fn normalize(&mut self)
pub fn normalize(&mut self)
Kernel normalization is designed to ensure that any use of the kernel scaling factor with ‘Convolve’ or ‘Correlate’ morphology methods will fall into -1.0 to +1.0 range. Note that for non-HDRI versions of IM this may cause images to have any negative results clipped, unless some ‘bias’ is used.
More specifically. Kernels which only contain positive values (such as a ‘Gaussian’ kernel) will be scaled so that those values sum to +1.0, ensuring a 0.0 to +1.0 output range for non-HDRI images.
For Kernels that contain some negative values, (such as ‘Sharpen’ kernels) the kernel will be scaled by the absolute of the sum of kernel values, so that it will generally fall within the +/- 1.0 range.
For kernels whose values sum to zero, (such as ‘Laplacian’ kernels) kernel will be scaled by just the sum of the positive values, so that its output range will again fall into the +/- 1.0 range.
sourcepub fn correlate_normalize(&mut self)
pub fn correlate_normalize(&mut self)
For special kernels designed for locating shapes using ‘Correlate’, (often only containing +1 and -1 values, representing foreground/background matching) a special normalization method is provided to scale the positive values separately to those of the negative values, so the kernel will be forced to become a zero-sum kernel better suited to such searches.
sourcepub fn unity_add(&mut self, scale: f64)
pub fn unity_add(&mut self, scale: f64)
Adds a given amount of the ‘Unity’ Convolution Kernel to the given pre-scaled and normalized Kernel. This in effect adds that amount of the original image into the resulting convolution kernel. This value is usually provided by the user as a percentage value in the ‘convolve:scale’ setting.
The resulting effect is to convert the defined kernels into blended soft-blurs, unsharp kernels or into sharpening kernels.