Platforms to show: All Mac Windows Linux Cross-Platform

Back to IMKernelInfo7MBS class.

IMKernelInfo7MBS.Clone as IMKernelInfo7MBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method ImageMagick7 MBS GraphicsMagick Plugin 20.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Clones the kernel info object.

Creates a new clone of the given Kernel List so that its can be modified without effecting the original.

IMKernelInfo7MBS.Constructor(KernelInfo as IMKernelInfo7MBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method ImageMagick7 MBS GraphicsMagick Plugin 20.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Creates a copy of the kernel.

See also:

IMKernelInfo7MBS.Constructor(kernelString as String)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method ImageMagick7 MBS GraphicsMagick Plugin 20.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Takes the given string (generally supplied by the user) and converts it into a Morphology/Convolution Kernel.

This allows users to specify a kernel from a number of pre-defined kernels, or to fully specify their own kernel for a specific Convolution or Morphology Operation.

The kernel so generated can be any rectangular array of floating point values (doubles) with the 'control point' or 'pixel being affected' anywhere within that array of values.

Previously IM was restricted to a square of odd size using the exact center as origin, this is no longer the case, and any rectangular kernel with any value being declared the origin. This in turn allows the use of highly asymmetrical kernels.

The floating point values in the kernel can also include a special value known as 'nan' or 'not a number' to indicate that this value is not part of the kernel array. This allows you to shaped the kernel within its rectangular area. That is 'nan' values provide a 'mask' for the kernel shape. However at least one non-nan value must be provided for correct working of a kernel.

The returned kernel should be freed using the DestroyKernelInfo() when you are finished with it. Do not free this memory yourself.

Input kernel defintion strings can consist of any of three types.

"name:args[[@><]" Select from one of the built in kernels, using the name and geometry arguments supplied. See AcquireKernelBuiltIn()

"WxH[+X+Y][@><]:num, num, num ..." a kernel of size W by H, with W*H floating point numbers following. the 'center' can be optionally be defined at +X+Y (such that +0+0 is top left corner). If not defined the pixel in the center, for odd sizes, or to the immediate top or left of center for even sizes is automatically selected.

"num, num, num, num, ..." list of floating point numbers defining an 'old style' odd sized square kernel. At least 9 values should be provided for a 3x3 square kernel, 25 for a 5x5 square kernel, 49 for 7x7, etc. Values can be space or comma separated. This is not recommended.

You can define a 'list of kernels' which can be used by some morphology operators A list is defined as a semi-colon separated list kernels.

" kernel ; kernel ; kernel ; "

Any extra ';' characters, at start, end or between kernel defintions are simply ignored.

The special flags will expand a single kernel, into a list of rotated kernels. A '@' flag will expand a 3x3 kernel into a list of 45-degree cyclic rotations, while a '>' will generate a list of 90-degree rotations. The '<' also exands using 90-degree rotates, but giving a 180-degree reflected kernel before the +/- 90-degree rotations, which can be important for Thinning operations.

Note that 'name' kernels will start with an alphabetic character while the new kernel specification has a ':' character in its specification string. If neither is the case, it is assumed an old style of a simple list of numbers generating a odd-sized square kernel has been given.

kernelString: the Morphology/Convolution kernel wanted.

See also AcquireKernelInfo in ImageMagick documentation.

See also:

IMKernelInfo7MBS.Constructor(Type as Integer, GeometryInfo as IMGeometryInfo7MBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method ImageMagick7 MBS GraphicsMagick Plugin 20.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Returns one of the 'named' built-in types of kernels used for special purposes such as gaussian blurring, skeleton pruning, and edge distance determination.

They take a KernelType, and a set of geometry style arguments, which were typically decoded from a user supplied string, or from a more complex Morphology Method that was requested.

A description of each parameter follows:

type: the pre-defined type of kernel wanted
args: arguments defining or modifying the kernel

Convolution Kernels
Unity The a No-Op or Scaling single element kernel.
Gaussian:{radius},{sigma} Generate a two-dimensional gaussian kernel, as used by -gaussian. The sigma for the curve is required. The resulting kernel is normalized,
If 'sigma' is zero, you get a single pixel on a field of zeros.
NOTE: that the 'radius' is optional, but if provided can limit (clip) the final size of the resulting kernel to a square 2*radius+1 in size. The radius should be at least 2 times that of the sigma value, or sever clipping and aliasing may result. If not given or set to 0 the radius will be determined so as to produce the best minimal error result, which is usally much larger than is normally needed.
LoG:{radius},{sigma} "Laplacian of a Gaussian" or "Mexician Hat" Kernel. The supposed ideal edge detection, zero-summing kernel.
An alturnative to this kernel is to use a "DoG" with a sigma ratio of approx 1.6 (according to wikipedia).
DoG:{radius},{sigma1},{sigma2} "Difference of Gaussians" Kernel. As "Gaussian" but with a gaussian produced by 'sigma2' subtracted from the gaussian produced by 'sigma1'. Typically sigma2 > sigma1. The result is a zero-summing kernel.
Blur:{radius},{sigma}[,{angle}] Generates a 1 dimensional or linear gaussian blur, at the angle given (current restricted to orthogonal angles). If a 'radius' is given the kernel is clipped to a width of 2*radius+1. Kernel can be rotated by a 90 degree angle.
If 'sigma' is zero, you get a single pixel on a field of zeros.
Note that two convolutions with two "Blur" kernels perpendicular to each other, is equivalent to a far larger "Gaussian" kernel with the same sigma value, However it is much faster to apply. This is how the "-blur" operator actually works.
Comet:{width},{sigma},{angle} Blur in one direction only, much like how a bright object leaves a comet like trail. The Kernel is actually half a gaussian curve, Adding two such blurs in opposite directions produces a Blur Kernel. Angle can be rotated in multiples of 90 degrees.
Note that the first argument is the width of the kernel and not the radius of the kernel.
Binomial:[{radius}] Generate a discrete kernel using a 2 dimentional Pascel's Triangle of values. Used for special forma of image filters.

See also:

IMKernelInfo7MBS.Scale(scaleFactor as double, GeometryFlags as integer)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method ImageMagick7 MBS GraphicsMagick Plugin 20.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Scales the given kernel.

Scales the given kernel list by the given amount, with or without normalization of the sum of the kernel values (as per given flags).

By default (no flags given) the values within the kernel is scaled directly using given scaling factor without change.

If either of the two 'normalize_flags' are given the kernel will first be normalized and then further scaled by the scaling factor value given.

Kernel normalization ('normalize_flags' given) 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 'Laplician' kernels) kernel will be scaled by just the sum of the postive values, so that its output range will again fall into the +/- 1.0 range.

For special kernels designed for locating shapes using 'Correlate', (often only containing +1 and -1 values, representing foreground/brackground 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.

WARNING: Correct normalization of the kernel assumes that the '*_range' attributes within the kernel structure have been correctly set during the kernels creation.

NOTE: The values used for 'normalize_flags' have been selected specifically to match the use of geometry options, so that '!' means NormalizeValue, '^' means CorrelateNormalizeValue. All other GeometryFlags values are ignored.

scaleFactor: zero. If the kernel is normalized regardless of any flags.
GeometryFlags: specifically: NormalizeValue, CorrelateNormalizeValue, and/or PercentValue.

See also ScaleKernelInfo in ImageMagick documentation.

IMKernelInfo7MBS.ScaleGeometry(Geometry as string)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method ImageMagick7 MBS GraphicsMagick Plugin 20.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Scales using a geometry.

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.

The first argument (and any normalization flags) are passed to ScaleKernelInfo() to scale/normalize the kernel. The second argument is then passed to UnityAddKernelInfo() to add a scled unity kernel into the scaled/normalized kernel.

geometry: "-set option:convolve:scale {geometry}" setting.

See also ScaleGeometryKernelInfo in ImageMagick documentation.

IMKernelInfo7MBS.UnityAddKernelInfo(scale as double)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method ImageMagick7 MBS GraphicsMagick Plugin 20.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
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.

See also UnityAdditionKernelInfo in ImageMagick documentation.

The items on this page are in the following plugins: MBS GraphicsMagick Plugin.


The biggest plugin in space...