vImageLookupTable_PlanarFtoPlanar8(_:_:_:_:)
Uses a lookup table to transform a 32-bit planar image to an 8-bit planar image.
Declaration
func vImageLookupTable_PlanarFtoPlanar8(_ src: UnsafePointer<vImage_Buffer>, _ dest: UnsafePointer<vImage_Buffer>, _ table: UnsafePointer<Pixel_8>, _ flags: vImage_Flags) -> vImage_ErrorParameters
- src:
The source vImage buffer.
- dest:
A pointer to the destination vImage buffer structure. You’re responsible for filling out the
height,width, androwBytesfields 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. - table:
A lookup table that contains 4,096 Pixel_8 values.
- 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
This function maps the source pixels in the range 0...1 to the index values 0...4095. The per-pixel conversion calculation is equivalent to the following:
uint8_t table[4096];
uint32_t index = (uint32_t) MIN( MAX( input_float_pixel * 4096.0f, 0.0f), 4095.0f);
uint8_t result_pixel = table[ index ];You can use this function with multichannel data by scaling the width of the image to compensate for the additional channels. In this case, all channels use the same lookup table.
This function works in place, provided that src->data == dest->data and src->rowBytes >= dest->rowBytes. If src->rowBytes > dest->rowBytes, pass the kvImageDoNotTile flag.