CIFilter_Stylize_Convolution9Horizontal - linhay/Stem GitHub Wiki

CIFilter.Stylize.Convolution9Horizontal

Discussion A convolution filter generates each output pixel by summing all elements in the element-wise product of two matrices—a weight matrix and a matrix containing the neighborhood surrounding the corresponding input pixel—and adding a bias. This operation is performed independently for each color component (including the alpha component), and the resulting value is clamped to the range between 0.0 and 1.0. You can create many types of image processing effects using different weight matrices, such as blurring, sharpening, edge detection, translation, and embossing. This filter uses a 9x1 weight matrix and the 9x1 neighborhood surrounding an input pixel (that is, the pixel itself and those within a distance of four pixels horizontally). Unlike convolution filters which use square matrices, this filter can only produce effects along a horizontal axis, but it can be combined with CIConvolution9Vertical to approximate the effect of certain 9x9 weight matrices. If you want to preserve the overall brightness of the image, ensure that the sum of all values in the weight matrix is 1.0. You may find it convenient to devise a weight matrix without this constraint and then normalize it by dividing each element by the sum of all elements.

public struct Convolution9Horizontal: CIFilterContainerProtocol

Inheritance

CIFilterContainerProtocol

Initializers

init()

init()

Properties

filter

var filter: CIFilter

image

A CIImage object whose display name is Image.

var image: CIImage?

weights

A CIVector object whose display name is Weights. Default value: [0 0 0 0 1 0 0 0 0] Identity: [0 0 0 0 1 0 0 0 0]

var weights: CIVector

bias

An NSNumber object whose attribute type is CIAttributeTypeDistance and whose display name is Bias. Default value: 0.00 Identity: 0.00

var bias: NSNumber