---
title: vImage.MultidimensionalLookupTable
framework: accelerate
role: symbol
role_heading: Structure
path: accelerate/vimage/multidimensionallookuptable
---

# vImage.MultidimensionalLookupTable

A multidimensional lookup table.

## Declaration

```swift
struct MultidimensionalLookupTable
```

## Mentioned in

Applying color transforms to images with a multidimensional lookup table

## Overview

Overview 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 given input color. A vImage.MultidimensionalLookupTable applies transforms to 32-bit planar pixel buffers. There are pixel buffer functions available to convert between bit depths and interleaved to planar buffers. The following is an example of a simple lookup table that implements the Rec. 709 luma coefficients to convert from a 3-channel RGB image to a single-channel grayscale image. The lookup table is a 3D cube with 32 entries per channel. 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 } Use the lookup table data to create a vImage.MultidimensionalLookupTable structure. let entryCountPerSourceChannel = [UInt8](repeating: entriesPerChannel,                                          count: srcChannelCount)

let lookupTable = vImage.MultidimensionalLookupTable(     entryCountPerSourceChannel: entryCountPerSourceChannel,     destinationChannelCount: destChannelCount,     data: tableData) Call the `apply(sources:destinations:interpolation:)` function to transform a 3-channel RGB image to a grayscale image. In this example, the source is interleaved. The code demonstrates calling planarBuffers() to deinterleave the source. let src = vImage.PixelBuffer<vImage.InterleavedFx3>( ... )

let planarSources = src.planarBuffers()

let dest = vImage.PixelBuffer<vImage.PlanarF>(size: src.size)

lookupTable.apply(sources: planarSources,                   destinations: [dest],                   interpolation: .none) On return, dest contains a grayscale representation of the source RGB image.

## Topics

### Initializers

- [init(entryCountPerSourceChannel:destinationChannelCount:data:)](accelerate/vimage/multidimensionallookuptable/init(entrycountpersourcechannel:destinationchannelcount:data:).md)

### Instance Properties

- [destinationChannelCount](accelerate/vimage/multidimensionallookuptable/destinationchannelcount.md)
- [entryCountPerSourceChannel](accelerate/vimage/multidimensionallookuptable/entrycountpersourcechannel.md)
- [sourceChannelCount](accelerate/vimage/multidimensionallookuptable/sourcechannelcount.md)

### Instance Methods

- [apply(source:destination:interpolation:)](accelerate/vimage/multidimensionallookuptable/apply(source:destination:interpolation:).md)
- [apply(sources:destinations:interpolation:)](accelerate/vimage/multidimensionallookuptable/apply(sources:destinations:interpolation:).md)

### Enumerations

- [vImage.MultidimensionalLookupTable.InterpolationMethod](accelerate/vimage/multidimensionallookuptable/interpolationmethod.md)

## See Also

### Related Documentation

- [Applying color transforms to images with a multidimensional lookup table](accelerate/applying-color-transforms-to-images-with-a-multidimensional-lookup-table.md)

### Type Aliases

- [vImage.StructuringElement](accelerate/vimage/structuringelement.md)
- [vImage.ConvolutionKernel](accelerate/vimage/convolutionkernel.md)
- [vImage.ConvolutionKernel2D](accelerate/vimage/convolutionkernel2d.md)
- [vImage.DynamicPixelFormat](accelerate/vimage/dynamicpixelformat.md)
- [vImage.Interleaved16Fx2](accelerate/vimage/interleaved16fx2.md)
- [vImage.Interleaved16Fx4](accelerate/vimage/interleaved16fx4.md)
- [vImage.Interleaved16Ux2](accelerate/vimage/interleaved16ux2.md)
- [vImage.Interleaved16Ux4](accelerate/vimage/interleaved16ux4.md)
- [vImage.Interleaved8x2](accelerate/vimage/interleaved8x2.md)
- [vImage.Interleaved8x3](accelerate/vimage/interleaved8x3.md)
- [vImage.Interleaved8x4](accelerate/vimage/interleaved8x4.md)
- [vImage.InterleavedFx2](accelerate/vimage/interleavedfx2.md)
- [vImage.InterleavedFx3](accelerate/vimage/interleavedfx3.md)
- [vImage.InterleavedFx4](accelerate/vimage/interleavedfx4.md)
- [vImage.Options](accelerate/vimage/options.md)
