Applies a set of piecewise polynomials to transform an image in PlanarF format to an image in Planar8 format.

SDKs

- iOS 5.0+
- macOS 10.4+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+

Framework

- Accelerate

## Declaration

## Parameters

`src`

A pointer to a vImage buffer structure that contains the source image.

`dest`

A pointer to a vImage buffer data structure. You're responsible for filling out the

`height`

,`width`

, and`row`

fields of this structure, and for allocating a data buffer of the appropriate size. On return, the data buffer this structure points to contains the destination image data. When you no longer need the data buffer, you must deallocate the memoryBytes `coefficients`

A pointer to an array of polynomial coefficient arrays. Each polynomial coefficient array contains the coefficients for one polynomial. Note that a polynomial of order R has R+1 coefficients. All the polynomial coefficient arrays must be the same size, R+1, and in each array the coefficients must be ordered from the 0th-order term to the highest-order term.

`boundaries`

A pointer to an array of boundary values, in increasing order, for separating adjacent ranges of pixel values. The first boundary value is the lowest in the range; input values lower than this are clipped to this value. The last boundary value is the highest in the range; input values higher than this are clipped to this value. The boundary values between the first and last separate the subranges from each other.

`log2segments`

The number of polynomials represented as a base-2 logarithm. If you pass a non-integer power-of-two number of polynomials (for example, 5), you must round up to the next integer power of 2 (for the example of 5, that would be 8), and simply repeat the last polynomial the appropriate number of times.

`flags`

Reserved for future use; pass 0.

## Return Value

`kv`

; otherwise, one of the error codes described in Data Types and Constants.

## Discussion

You can approximate many different correction functions by carefully choosing the polynomials and the ranges of input values they operate on. The number of polynomials must be a non-negative integer power of 2.

Suppose that you want to use N polynomials of order R to process N contiguous ranges of pixel values. For each pixel in the image, the range of usable values is divided into segments by the values passed in the `boundaries`

array. Each segment is processed by the corresponding polynomial. Since there are N polynomials, then there must be N segments, so you must supply N+1 boundaries.

You must order the boundaries by increasing value. The ith segment is the set of pixel values that fall in the range:

where i ranges from 0 to N. Values in this segment are processed by the i-th polynomial.

From a performance standpoint, it costs much more to resolve additional polynomials than to work with higher-order polynomials. You typically achieve better performance with one 9th-order polynomial that covers the whole range of values you are interested in than with many lower-order polynomials covering the range piecewise.

This function uses single-precision floating-point arithmetic. As a result, polynomials with large high-order coefficients may cause significant rounding error.