---
title: "applyLookup(_:destination:)"
framework: accelerate
role: symbol
role_heading: Instance Method
path: "accelerate/vimage/pixelbuffer/applylookup(_:destination:)-1tsb5"
---

# applyLookup(_:destination:)

Applies a lookup table to transform an 8-bit planar image to a 32-bit-per-channel, three-channel interleaved image.

## Declaration

```swift
func applyLookup(_ lookupTable: [Pixel_FFFF], destination: vImage.PixelBuffer<vImage.InterleavedFx3>)
```

## Parameters

- `lookupTable`: A lookup table that contains 256 doc://com.apple.accelerate/documentation/Accelerate/Pixel_FFFF ARGB values. The function discards the alpha component.
- `destination`: The destination pixel buffer.

## Discussion

Discussion You can use this function to create pseudo-color images by transforming a grayscale image to an RGB image. The following code creates a simple lookup table with a high red response for low values, a high green response for middle values, and a high blue response for large values: let window = vDSP.window(ofType: Float.self,                          usingSequence: .blackman,                          count: 256,                          isHalfWindow: false)

let lookup: [Pixel_FFFF] = (0 ..< 256).map { i in          let red = window[ max(0, min(127 - i, 255))]     let green = window[i]     let blue = window[ max(0, min(382 - i, 255))]          return Pixel_FFFF(0, red, green, blue) } The graph below visualizes the values in the lookup table:

Use the following code to apply the lookup table to a vImage.Planar8 source buffer with a vImage.InterleavedFx3 destination buffer: let destinationBuffer = vImage.PixelBuffer (     size: sourceBuffer.size,     pixelFormat: vImage.InterleavedFx3.self)

sourceBuffer.applyLookup(lookup, destination: destinationBuffer) The images below show an example grayscale source image on the left and the pseudo-color result on the right. The operation converts dark areas in the source to red in the destination, and light areas in the source to blue in the destination.

## See Also

### Transforming with a lookup table

- [applyLookup(_:destination:)](accelerate/vimage/pixelbuffer/applylookup(_:destination:)-5r7bq.md)
- [applyLookup(_:destination:)](accelerate/vimage/pixelbuffer/applylookup(_:destination:)-14pjo.md)
- [applyLookup(_:destination:)](accelerate/vimage/pixelbuffer/applylookup(_:destination:)-5oi4o.md)
- [applyLookup(_:destination:)](accelerate/vimage/pixelbuffer/applylookup(_:destination:)-3ruls.md)
- [applyLookup(alphaTable:redTable:greenTable:blueTable:destination:)](accelerate/vimage/pixelbuffer/applylookup(alphatable:redtable:greentable:bluetable:destination:).md)
