Transform

Apply color transformations to images.

Overview

Transformation functions alter the values of pixels in the image. Unlike convolutions, transformation functions do not depend on the values of nearby pixels. The vImage transformation functions fall into four broad categories:

  • Gamma correction functions correct the brightness profile of an image by multiplying each pixel by the value of the function. Gamma correction prepares an image for display or printing on a particular device.

  • Lookup table functions are like the piecewise polynomial functions, but instead of applying a polynomial they use a lookup table that you supply.

  • Matrix multiplication functions have a variety of uses, such as to convert between color spaces (RGB and YUV, for example), change a color image to a grayscale one, and for “color twisting.”

  • Piecewise functions are similar to the gamma correction functions, but instead of applying a predefined gamma function they apply one or more polynomials that you supply. The number of polynomials must be an integer power of 2, and they must all be of the same order.

Transformation functions use a vImage buffer structure (vImage_Buffer—see Data Types and Constants) to receive and supply image data. This buffer contains a pointer to image data, the height and width (in pixels) of the image data, and the number of row bytes. You actually pass a pointer to a vImage buffer structure.

Some transformation functions “work in place”. That is, the source and destination images can occupy the same memory if the they are strictly aligned pixel for pixel. For these, you can can provide a pointer to the same vImage buffer structure for one of the source images and the destination image.

Topics

Transforming with a Lookup Table

func vImageLookupTable_8to64U(UnsafePointer<vImage_Buffer>, UnsafePointer<vImage_Buffer>, UnsafePointer<UInt64>, vImage_Flags) -> vImage_Error

Uses a lookup table to remap 8-bit unsigned integers in a source image to 64-bit unsigned values.

Transforming with a Multidimensional Lookup Table

typealias vImage_MultidimensionalTable

A structure representing a multidimensional table for use with vImage's multidimensional interpolated lookup functions.

struct vImageMDTableUsageHint

Constants that indicate how a multidimensional table will be used.

struct vImage_InterpolationMethod

Constants that represent different interpolation methods.

Applying a Polynomial

Multiplying Pixels by a Matrix

func vImageMatrixMultiply_ARGB8888(UnsafePointer<vImage_Buffer>, UnsafePointer<vImage_Buffer>, UnsafePointer<Int16>, Int32, UnsafePointer<Int16>!, UnsafePointer<Int32>!, vImage_Flags) -> vImage_Error

Operates on an interleaved 8-bit source image, multiplying each pixel by the provided matrix to produce an interleaved 8-bit destination image.

func vImageMatrixMultiply_ARGBFFFF(UnsafePointer<vImage_Buffer>, UnsafePointer<vImage_Buffer>, UnsafePointer<Float>, UnsafePointer<Float>!, UnsafePointer<Float>!, vImage_Flags) -> vImage_Error

Operates on an interleaved floating-point source image, multiplying each pixel by the provided matrix to produce an interleaved floating-point destination image.

func vImageMatrixMultiply_ARGB8888ToPlanar8(UnsafePointer<vImage_Buffer>, UnsafePointer<vImage_Buffer>, UnsafePointer<Int16>, Int32, UnsafePointer<Int16>!, Int32, vImage_Flags) -> vImage_Error

Operates on an interleaved 8-bit source image, multiplying each pixel by the provided matrix to produce a one-channel 8-bit destination image.

func vImageMatrixMultiply_ARGBFFFFToPlanarF(UnsafePointer<vImage_Buffer>, UnsafePointer<vImage_Buffer>, UnsafePointer<Float>, UnsafePointer<Float>!, Float, vImage_Flags) -> vImage_Error

Operates on an interleaved 32-bit source image, multiplying each pixel by the provided matrix to produce a one-channel 32-bit destination image.

Correcting Gamma

func vImageDestroyGammaFunction(GammaFunction!)

Destroys a gamma function object created.

Constants

Gamma Function Types

Types of full- or half-precision gamma functions.

See Also