<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Accelerate",
  "identifier" : "/documentation/Accelerate/vImage/MultidimensionalLookupTable",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Accelerate"
    ],
    "preciseIdentifier" : "s:10Accelerate6vImageO27MultidimensionalLookupTableV"
  },
  "title" : "vImage.MultidimensionalLookupTable"
}
-->

# vImage.MultidimensionalLookupTable

A multidimensional lookup table.

```
struct MultidimensionalLookupTable
```

## 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`](/documentation/Accelerate/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.

```swift
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`](/documentation/Accelerate/vImage/MultidimensionalLookupTable) structure.

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

let lookupTable = vImage.MultidimensionalLookupTable(
    entryCountPerSourceChannel: entryCountPerSourceChannel,
    destinationChannelCount: destChannelCount,
    data: tableData)
```

Call the `[`apply(sources:destinations:interpolation:)`](/documentation/Accelerate/vImage/MultidimensionalLookupTable/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()`](/documentation/Accelerate/vImage/PixelBuffer/planarBuffers()-462ja) to deinterleave the source.

```swift
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<T>(entryCountPerSourceChannel: [UInt8], destinationChannelCount: Int, data: T)`](/documentation/Accelerate/vImage/MultidimensionalLookupTable/init(entryCountPerSourceChannel:destinationChannelCount:data:))

Returns a new multidimensional lookup table.

### Instance Properties

[`let destinationChannelCount: Int`](/documentation/Accelerate/vImage/MultidimensionalLookupTable/destinationChannelCount)

The number of destination channels.

[`let entryCountPerSourceChannel: [UInt8]`](/documentation/Accelerate/vImage/MultidimensionalLookupTable/entryCountPerSourceChannel)

An array that contains the number of table entries for each dimension of the lookup table.

[`let sourceChannelCount: Int`](/documentation/Accelerate/vImage/MultidimensionalLookupTable/sourceChannelCount)

The number of source channels.

### Instance Methods

[`func apply<SrcFormat, DestFormat>(source: vImage.PixelBuffer<SrcFormat>, destination: vImage.PixelBuffer<DestFormat>, interpolation: vImage.MultidimensionalLookupTable.InterpolationMethod)`](/documentation/Accelerate/vImage/MultidimensionalLookupTable/apply(source:destination:interpolation:))

Transforms a multiple plane pixel buffer using the multidimensional lookup table.

[`func apply(sources: [vImage.PixelBuffer<vImage.PlanarF>], destinations: [vImage.PixelBuffer<vImage.PlanarF>], interpolation: vImage.MultidimensionalLookupTable.InterpolationMethod)`](/documentation/Accelerate/vImage/MultidimensionalLookupTable/apply(sources:destinations:interpolation:))

Transforms an array of planar pixel buffers using the multidimensional lookup table.

### Enumerations

[`enum InterpolationMethod`](/documentation/Accelerate/vImage/MultidimensionalLookupTable/InterpolationMethod)

Describes the method a multidimensional lookup table uses the generate interpolated values between lookup table values.

## See Also

  <doc://com.apple.accelerate/documentation/Accelerate/applying-color-transforms-to-images-with-a-multidimensional-lookup-table>



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)