Contents

applyPolynomial(coefficientSegments:boundaries:destination:)

Applies a set of piecewise polynomials to a 2-channel, 32-bit interleaved buffer.

Declaration

func applyPolynomial(coefficientSegments: [[Float]], boundaries: [Float], destination: vImage.PixelBuffer<Format>)

Parameters

  • coefficientSegments:

    An array that contains the polynomial coefficient array. Each polynomial must be of the same order.

  • boundaries:

    An array of boundary values, in increasing order, that separates adjacent ranges of pixel values. boundaries must contain coefficientSegments.count + 1 elements.

  • destination:

    The destination pixel buffer.

Discussion

The following code shows an example of applying three polynomials to an vImage.InterleavedFx2 buffer:

let src = vImage.PixelBuffer<vImage.InterleavedFx2>(
    pixelValues: [0.25, 0.5, 0.75, 1.0],
    size: vImage.Size(width: 2, height: 1))

let dest = vImage.PixelBuffer<vImage.InterleavedFx2>(
    size: src.size)

src.applyPolynomial(coefficientSegments: [ [1, 0, 0],
                                           [0, 1, 0],
                                           [0, 0, 1] ],
                    boundaries: [0, 1/3, 2/3, 1] as [Float],
                    destination: dest)

// Prints:
//  1.0     ≅ 1 * 0.25⁰

//  0.5     ≅ 1 * 0.5¹

//  0.5625  ≅ 1 * 0.75²
//  1.0     ≅ 1 * 1.0²
print(dest.array)

See Also

Related Documentation

Appying polynomial (32-bit)