Returns a gamma function object.


func vImageCreateGammaFunction(_ gamma: Float, _ gamma_type: Int32, _ flags: vImage_Flags) -> GammaFunction!



The exponent of a power function for calculating full-precision gamma correction.


A selector for the type of gamma correction to use. Pass one of the full- or half-precision type constants defined in Gamma Function Types.


The options to use when performing the operation. If you plan to perform your own tiling or use multithreading, pass kvImageDoNotTile.

Return Value

A gamma function object that encapsulates a gamma value, a gamma function type, and option flags.


You can pass a gamma function object to any of the three gamma correction functions: vImageGamma_Planar8toPlanarF(_:_:_:_:), vImageGamma_PlanarFtoPlanar8(_:_:_:_:), vImageGamma_PlanarF(_:_:_:_:).

The gamma-type parameter determines the type of calculation to be used. The simplest calculation is:

if (value == 0) result = 0;
else {
    if (value < 0)
        sign = -1.0f;
        sign = 1.0f;
    result = pow( fabs( value ), gamma) * sign;

This calculation results in symmetric gamma curves about 0, and makes sure that only well-behaved values are used in pow().

You can use an equivalent calculation that uses a more efficient method, depending on the desired precision.

In addition to the full-precision gamma correction, there is a faster half-precision option that provides 12-bit precision.

f your data will ultimately be converted to 8-bit integer data, consider using half-precision. The half-precision variants work correctly only for floating-point input values in the range 0.0 ... 1.0, though out-of-range values produce results that clamp appropriately to 0 or 255 on conversion back to 8-bit. In addition, there are restrictions on the range of the exponent: it must be positive, in the range 0.1 to 10.0.

Finally, there is a set of still faster half-precision options that use predefined gamma values, ignoring the value set in vImageCreateGammaFunction. These options have the same restrictions on input values as stated previously.

See Also

Correcting Gamma

func vImageDestroyGammaFunction(GammaFunction!)

Destroys a gamma function object created.