Function

vImageCreateGammaFunction

Returns a gamma function object.

Declaration

GammaFunction vImageCreateGammaFunction(float gamma, int gamma_type, vImage_Flags flags);

Parameters

gamma

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

gamma_type

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.

flags

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.

Discussion

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;
    else
        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

vImageDestroyGammaFunction

Destroys a gamma function object created.

vImageGamma_Planar8toPlanarF

Applies a gamma function to a Planar8 image to produce a PlanarF image.

vImageGamma_PlanarFtoPlanar8

Applies a gamma function to an image in PlanarF format to an image in Planar8 format.

vImageGamma_PlanarF

Applies a gamma function to a PlanarF image.

vImagePiecewiseGamma_Planar8

Applies a piecewise gamma function to a Planar8 image.

vImagePiecewiseGamma_Planar8toPlanar16Q12

Applies a piecewise gamma function to a Planar8 image to produce a Planar16Q12 image.

vImagePiecewiseGamma_Planar8toPlanarF

Applies a piecewise gamma function to a Planar8 image to produce a PlanarF image.

vImagePiecewiseGamma_Planar16Q12

Applies a piecewise gamma function to a Planar16Q12 image.

vImagePiecewiseGamma_Planar16Q12toPlanar8

Applies a piecewise gamma function to a Planar16Q12 image to produce a Planar8 image.

vImagePiecewiseGamma_PlanarF

Applies a piecewise gamma function to a PlanarF image.

vImagePiecewiseGamma_PlanarFtoPlanar8

Applies a piecewise gamma function to a PlanarF image to produce a Planar8 image.

vImageSymmetricPiecewiseGamma_Planar16Q12

Applies a symmetric piecewise gamma function to a Planar16Q12 image.

vImageSymmetricPiecewiseGamma_PlanarF

Applies a symmetric piecewise gamma function to a PlanarF image.