Generic Static Method

convolve(_:dereference:kernel:)

Converts an image data buffer to a pixel array, using the given pixel kernel and dereferencing function.

Declaration

static func convolve<A, T, C>(_ buffer:[UInt8], dereference:(Int) -> A, kernel:(T) -> C) -> [C] where A:FixedWidthInteger & UnsignedInteger, T:FixedWidthInteger & UnsignedInteger

Parameters

buffer

An image data buffer.

dereference

A dereferencing function.

kernel

A pixel kernel.

Return value

An array of pixels constructed by the given kernel function. This array has the same number of elements as buffer.

Overview

This function casts each byte in buffer to an Int index, and passes each index to the given dereference function, receiving scalar atoms of type A in return. It then scales the atoms to the range of T, and constructs instances of C by mapping the given kernel function over each T scalar.

A worked example of how to use this function to implement a custom color target can be found in the custom color targets tutorial.

Topics

See also

static func convolve<A, T, C>([UInt8], dereference:(Int) -> (A, A), kernel:((T, T)) -> C) -> [C]

Converts an image data buffer to a pixel array, using the given pixel kernel and dereferencing function.

static func convolve<A, T, C>([UInt8], dereference:(Int) -> (A, A, A), kernel:((T, T, T)) -> C) -> [C]

Converts an image data buffer to a pixel array, using the given pixel kernel and dereferencing function.

static func convolve<A, T, C>([UInt8], dereference:(Int) -> (A, A, A, A), kernel:((T, T, T, T)) -> C) -> [C]

Converts an image data buffer to a pixel array, using the given pixel kernel and dereferencing function.

static func convolve<A, T, C>([UInt8], of:A.Type, depth:Int, kernel:(T, A) -> C) -> [C]

Converts an image data buffer to a pixel array, using the given pixel kernel.

static func convolve<A, T, C>([UInt8], of:A.Type, depth:Int, kernel:((T, T)) -> C) -> [C]

Converts an image data buffer to a pixel array, using the given pixel kernel.

static func convolve<A, T, C>([UInt8], of:A.Type, depth:Int, kernel:((T, T, T), (A, A, A)) -> C) -> [C]

Converts an image data buffer to a pixel array, using the given pixel kernel.

static func convolve<A, T, C>([UInt8], of:A.Type, depth:Int, kernel:((T, T, T, T)) -> C) -> [C]

Converts an image data buffer to a pixel array, using the given pixel kernel.