<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: -",
    "macOS: 14.0.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: -",
    "watchOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Accelerate",
  "identifier" : "/documentation/Accelerate/vImage/PixelBuffer/applyLookup(_:destination:)-3ruls",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Accelerate"
    ],
    "preciseIdentifier" : "s:10Accelerate6vImageO11PixelBufferVAaC7Planar8VRszrlE11applyLookup_11destinationySays5UInt8V_A3KtG_AEy_AC14Interleaved8x3VGtF"
  },
  "title" : "applyLookup(_:destination:)"
}
-->

# applyLookup(_:destination:)

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

```
func applyLookup(_ lookupTable: [Pixel_8888], destination: vImage.PixelBuffer<vImage.Interleaved8x3>)
```

## Parameters

`lookupTable`

A lookup table that contains 256 [`Pixel_8888`](/documentation/Accelerate/Pixel_8888) ARGB values. The function discards the alpha component.

`destination`

The destination pixel buffer.

## 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:

```swift
let window = vDSP.window(ofType: Float.self,
                         usingSequence: .blackman,
                         count: 256,
                         isHalfWindow: false)

let lookup: [Pixel_8888] = (0 ..< 256).map { i in
    
    let red = Pixel_8(window[ max(0, min(127 - i, 255))] * 255)
    let green = Pixel_8(window[i] * 255)
    let blue = Pixel_8(window[ max(0, min(382 - i, 255))] * 255)

    return Pixel_8888(0, red, green, blue)
}
```

The graph below visualizes the values in the lookup table:

![A line chart with three series. The dotted line represents the red values that peaks at the left and curves to zero at the middle. The solid line represents the green values that starts on the left at zero, peaks in the middle, and drops to zero at the right. The dashed line represents the blue values that starts at zero in the middle and peaks at the right.](images/com.apple.accelerate/media-4164668@2x.png)

Use the following code to apply the lookup table to a [`vImage.Planar8`](/documentation/Accelerate/vImage/Planar8) source buffer with a [`vImage.Interleaved8x3`](/documentation/Accelerate/vImage/Interleaved8x3) destination buffer:

```swift
let destinationBuffer = vImage.PixelBuffer (
    size: sourceBuffer.size,
    pixelFormat: vImage.Interleaved8x3.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.

![Two versions of a close-up image of a fruit tree. On the left is the original grayscale image, and on the right is the transformed RGB color image.](images/com.apple.accelerate/media-4164667@2x.png)

---

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)