Contents

vImagePiecewiseGamma_PlanarFtoPlanar8(_:_:_:_:_:_:_:)

Applies a piecewise gamma function to transform a 32-bit planar image to an 8-bit planar image.

Declaration

func vImagePiecewiseGamma_PlanarFtoPlanar8(_ src: UnsafePointer<vImage_Buffer>, _ dest: UnsafePointer<vImage_Buffer>, _ exponentialCoeffs: UnsafePointer<Float>, _ gamma: Float, _ linearCoeffs: UnsafePointer<Float>, _ boundary: Float, _ flags: vImage_Flags) -> vImage_Error

Parameters

  • src:

    The source vImage buffer.

  • dest:

    A pointer to the destination vImage buffer structure. You’re responsible for filling out the height, width, and rowBytes 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, 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.

The following describes the operation with x representing the input pixel value:

if x < boundary:    
    scale = linearCoeffs[0]
    bias = linearCoeffs[1]

    r = scale * x + bias
else:    
    scale = exponentialCoeffs[0]
    prebias = exponentialCoeffs[1]
    postbias = exponentialCoeffs[2]

    t = scale * x + prebias
    r = pow(t, gamma) + postbias
output pixel value = r

See Also

Applying a piecewise gamma function