Function

vImageMatrixMultiply_ARGB8888ToPlanar8

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

Declaration

vImage_Error vImageMatrixMultiply_ARGB8888ToPlanar8(const vImage_Buffer *src, const vImage_Buffer *dest, const int16_t matrix[4], int32_t divisor, const int16_t pre_bias[4], int32_t post_bias, vImage_Flags flags);

Parameters

src

A pointer to a vImage buffer structure that contains the source image.

dest

A pointer to a vImage buffer data structure. You are 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 pointed to by this structure contains the destination image data. When you no longer need the data buffer, you must deallocate the memory.

matrix

The 1D matrix by which to multiply each pixel.

divisor

A divisor for normalization after performing the matrix multiplication.

pre_bias

A packed array of bias values, one for each source plane. vImage adds the appropriate bias value to each source value before matrix multiplication. If you don't want to apply a preprocessing bias value, pass NULL.

post_bias

A value added to the sum at the end to provide both for rounding control and for allowing for a bias to be encoded into the image format.

flags

The options to use when performing this operation. The following flags are supported:

kvImageNoFlags

Default operation.

kvImageDoNotTile

Disables internal multithreading.

kvImagePrintDiagnosticsToConsole

Prints diagnostic information to the console in the event of failure.

Return Value

kvImageNoError; otherwise, one of the error codes described in Data Types and Constants.

Discussion

This function is similar to vImageMatrixMultiply_ARGB8888 but produces a single channel output. It’s intended to produce grayscale images from four channel content, but can be used for other purposes.

The calculation for each pixel is:

int32_t p = (pixel[y][x][0] + pre_bias[0]) * matrix[0]  +                                  
            (pixel[y][x][1] + pre_bias[1]) * matrix[1]  +                                  
            (pixel[y][x][2] + pre_bias[2]) * matrix[2]  +                                  
            (pixel[y][x][3] + pre_bias[3]) * matrix[3];                      
 
result[y][x] = CLAMP( ( p + post_bias ) / divisor, 0, 0xff);

This function will work in place, provided that src->data = dest->data and src->rowBytes = dest->rowBytes.

See Also

Multiplying Pixels by a Matrix

vImageMatrixMultiply_Planar8

Operates on a set of 8-bit source image planes, multiplying each pixel by the provided matrix to produce a set of 8-bit destination image planes.

vImageMatrixMultiply_Planar16S

Operates on a set of 16-bit source image planes, multiplying each pixel by the provided matrix to produce a set of 16-bit destination image planes.

vImageMatrixMultiply_PlanarF

Operates on a set of floating-point source image planes, multiplying each pixel by the provided matrix to produce a set of floating-point destination image planes.

vImageMatrixMultiply_ARGB8888

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

vImageMatrixMultiply_ARGBFFFF

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

vImageMatrixMultiply_ARGBFFFFToPlanarF

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