---
title: "vImageMultidimensionalTable_Create(_:_:_:_:_:_:_:)"
framework: accelerate
role: symbol
role_heading: Function
path: "accelerate/vimagemultidimensionaltable_create(_:_:_:_:_:_:_:)"
---

# vImageMultidimensionalTable_Create(_:_:_:_:_:_:_:)

Creates a multidimensional lookup table.

## Declaration

```swift
func vImageMultidimensionalTable_Create(_ tableData: UnsafePointer<UInt16>, _ numSrcChannels: UInt32, _ numDestChannels: UInt32, _ table_entries_per_dimension: UnsafePointer<UInt8>, _ hint: vImageMDTableUsageHint, _ flags: vImage_Flags, _ err: UnsafeMutablePointer<vImage_Error>!) -> vImage_MultidimensionalTable!
```

## Parameters

- `tableData`: A pointer to the lookup table data.
- `numSrcChannels`: The number of channels in an input pixel.
- `numDestChannels`: The number of channels in an output pixel.
- `table_entries_per_dimension`: An array that contains the number of table entries for each channel in an input pixel.
- `hint`: A constant that specifies whether this function sets up the table for particular transform functions. If you only use doc://com.apple.accelerate/documentation/Accelerate/vImageMultiDimensionalInterpolatedLookupTable_PlanarF(_:_:_:_:_:_:), pass doc://com.apple.accelerate/documentation/Accelerate/kvImageMDTableHint_Float. If you only use doc://com.apple.accelerate/documentation/Accelerate/vImageMultiDimensionalInterpolatedLookupTable_Planar16Q12(_:_:_:_:_:_:), pass doc://com.apple.accelerate/documentation/Accelerate/kvImageMDTableHint_16Q12. Pass both flags if you use both transform functions.
- `flags`: The options to use when performing the operation. If your code implements its own tiling or its own multithreading, pass doc://com.apple.accelerate/documentation/Accelerate/kvImageDoNotTile; otherwise, pass doc://com.apple.accelerate/documentation/Accelerate/kvImageNoFlags.
- `err`: On output, doc://com.apple.accelerate/documentation/Accelerate/kvImageNoError; otherwise, one of the error codes in doc://com.apple.documentation/documentation/Accelerate/data-types-and-constants.

## Mentioned in

Applying color transforms to images with a multidimensional lookup table

## Return Value

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

## Discussion

Discussion Use a multidimensional lookup table to transform the colors in an image. The lookup table defines an output color based on the input color values. The vImage multidimensional lookup table provides interpolation to compute output color values that don’t have an explicit entry in the table for a specified input color. A vImage_MultidimensionalTable applies transforms to 32-bit and 16Q12 planar pixel buffers. The following is an example of a simple lookup table that implements the Rec. 709 luminance coefficients to convert from a three-channel RGB image to a single-channel grayscale image. The lookup table is a 3D cube with 32 entries per channel. Supply the lookup values as a contiguous array of samples that defines the lookup table values. The samples have range 0...65535 that the vImage library interprets as the floating-point range 0...1. let entriesPerChannel = UInt8(32) let srcChannelCount = 3 let destChannelCount = 1

let lookupTableElementCount = Int(pow(Float(entriesPerChannel),                                       Float(srcChannelCount))) * Int(destChannelCount)

let tableData = [UInt16](unsafeUninitializedCapacity: lookupTableElementCount) {     buffer, count in          let multiplier = Float(UInt16.max)     var bufferIndex = 0          for red in ( 0 ..< entriesPerChannel) {         for green in ( 0 ..< entriesPerChannel) {             for blue in ( 0 ..< entriesPerChannel) {                                  let normalizedRed = Float(red) / Float(entriesPerChannel - 1)                 let normalizedGreen = Float(green) / Float(entriesPerChannel - 1)                 let normalizedBlue = Float(blue) / Float(entriesPerChannel - 1)                                  let gray = (normalizedRed * 0.2126) +                            (normalizedGreen * 0.7152) +                            (normalizedBlue * 0.0722)                                  buffer[ bufferIndex ] = UInt16(gray * multiplier)                 bufferIndex += 1             }         }     }          count = lookupTableElementCount }

let entryCountPerSourceChannel = [UInt8](repeating: entriesPerChannel,                                          count: srcChannelCount)

var error = kvImageNoError

guard let lookupTable = vImageMultidimensionalTable_Create(         tableData,         UInt32(srcChannelCount),         UInt32(destChannelCount),         entryCountPerSourceChannel,         kvImageMDTableHint_Float,         vImage_Flags(kvImageNoFlags),         &error) else {     fatalError("Unable to create multidimensional table \(error).") }

defer {     vImageMultidimensionalTable_Release(lookupTable) }

## See Also

### Transforming with a multidimensional lookup table

- [Applying color transforms to images with a multidimensional lookup table](accelerate/applying-color-transforms-to-images-with-a-multidimensional-lookup-table.md)
- [Cropping to the subject in a chroma-keyed image](accelerate/cropping-to-the-subject-in-a-chroma-keyed-image.md)
- [Applying transformations to selected colors in an image](accelerate/applying-transformations-to-selected-colors-in-an-image.md)
- [vImageMultiDimensionalInterpolatedLookupTable_PlanarF(_:_:_:_:_:_:)](accelerate/vimagemultidimensionalinterpolatedlookuptable_planarf(_:_:_:_:_:_:).md)
- [vImageMultiDimensionalInterpolatedLookupTable_Planar16Q12(_:_:_:_:_:_:)](accelerate/vimagemultidimensionalinterpolatedlookuptable_planar16q12(_:_:_:_:_:_:).md)
- [vImageMultidimensionalTable_Retain(_:)](accelerate/vimagemultidimensionaltable_retain(_:).md)
- [vImageMultidimensionalTable_Release(_:)](accelerate/vimagemultidimensionaltable_release(_:).md)
- [vImage_MultidimensionalTable](accelerate/vimage_multidimensionaltable.md)
- [vImageMDTableUsageHint](accelerate/vimagemdtableusagehint.md)
- [vImage_InterpolationMethod](accelerate/vimage_interpolationmethod.md)
