applyPolynomial(coefficientSegments:boundaries:destination:)
Applies a set of piecewise polynomials to a 32-bit planar buffer and writes the result to an 8-bit planar buffer.
Declaration
func applyPolynomial(coefficientSegments: [[Float]], boundaries: [Float], destination: vImage.PixelBuffer<vImage.Planar8>)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.
boundariesmust containcoefficientSegments.count + 1elements. - destination:
The destination pixel buffer.
Discussion
The following code shows an example of applying three polynomials to a vImage.PlanarF buffer:
let src = vImage.PixelBuffer<vImage.PlanarF>(
pixelValues: [0.25, 0.5, 0.75, 1.0],
size: vImage.Size(width: 4, height: 1))
let dest = vImage.PixelBuffer<vImage.Planar8>(
size: src.size)
let factor = Float(255)
src.applyPolynomial(coefficientSegments: [ [1 * factor, 0, 0],
[0, 1 * factor, 0],
[0, 0, 1 * factor] ],
boundaries: [0, 1/3, 2/3, 1] as [Float],
destination: dest)
// Prints:
// 255 ≅ factor * 0.25⁰
// 127 ≅ factor * 0.5¹
// 143 ≅ factor * 0.75²
// 255 ≅ factor * 1.0²
print(dest.array)