vImageSymmetricPiecewiseGamma_PlanarF(_:_:_:_:_:_:_:)
Applies a symmetric piecewise gamma function to transform a 32-bit planar image.
Declaration
func vImageSymmetricPiecewiseGamma_PlanarF(_ src: UnsafePointer<vImage_Buffer>, _ dest: UnsafePointer<vImage_Buffer>, _ exponentialCoeffs: UnsafePointer<Float>, _ gamma: Float, _ linearCoeffs: UnsafePointer<Float>, _ boundary: Float, _ flags: vImage_Flags) -> vImage_ErrorParameters
- src:
The source vImage buffer.
- dest:
A pointer to the destination vImage buffer structure. You’re responsible for filling out the
height,width, androwBytesfields 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, deallocate the memory to prevent memory leaks. - exponentialCoeffs:
An array of three floating-point coefficients that specify the scale, prebias, and postbias for the gamma curve.
- gamma:
The power function exponent for calculating gamma correction for the gamma curve.
- linearCoeffs:
An array of two floating-point coefficients that specify the scale and bias for the linear curve.
- boundary:
A value that defines the boundary between the linear curve and the gamma curve.
- flags:
The options to use when performing the operation. If your code implements its own tiling or its own multithreading, pass Kvimagedonottile; otherwise, pass Kvimagenoflags.
Return Value
kvImageNoError; otherwise, one of the error codes in Data Types and Constants.
Discussion
The piecewise gamma calculation combines a linear and an exponential (gamma) curve on two regions of the input interval, separated by a specified boundary value. When the input is greater than or equal to the boundary value, the function uses the gamma curve to generate the output; otherwise, the function uses the linear curve. This function differs from vImagePiecewiseGamma_PlanarF(_:_:_:_:_:_:_:) in that it’s symmetric about zero.
The following describes the operation with x representing the input pixel value:
y = fabsf(x)
if y < boundary:
scale = linearCoeffs[0]
bias = linearCoeffs[1]
r = scale * y + bias
else:
scale = exponentialCoeffs[0]
prebias = exponentialCoeffs[1]
postbias = exponentialCoeffs[2]
t = scale * y + prebias
r = pow(t, gamma) + postbias
output pixel value = r * copysignf(1.0f, x)