---
title: "applyGamma(_:intermediateBuffer:destination:)"
framework: accelerate
role: symbol
role_heading: Instance Method
path: "accelerate/vimage/pixelbuffer/applygamma(_:intermediatebuffer:destination:)-3yu0w"
---

# applyGamma(_:intermediateBuffer:destination:)

Applies a gamma function to an 8-bit-per-channel, 3-channel interleaved pixel buffer.

## Declaration

```swift
func applyGamma(_ gamma: vImage.Gamma, intermediateBuffer: vImage.PixelBuffer<vImage.InterleavedFx3>? = nil, destination: vImage.PixelBuffer<vImage.Interleaved8x3>)
```

## Parameters

- `gamma`: An enumeration that specifies either a used-defined or constant gamma.
- `intermediateBuffer`: An optional intermediate buffer.
- `destination`: The destination pixel buffer.

## Discussion

Discussion This operation applies gamma to an vImage.Interleaved8x3 buffer by calling the underlying function vImageGamma_Planar8toPlanarF(_:_:_:_:). Therefore, it requires an intermediate vImage.InterleavedFx3 buffer. For the best performance, pass an existing vImage.InterleavedFx3 buffer to intermediateBuffer, alternatively, pass `nil` to specify that the function creates the intermediate buffer. For example, the following code applies a gamma of 2.0 to a one-pixel pixel buffer: let buffer = vImage.PixelBuffer<vImage.Interleaved8x3>(     pixelValues: [64, 128, 255],     size: vImage.Size(width: 1,                       height: 1))

buffer.applyGamma(.fullPrecision(2),                   destination: buffer)

// Prints "[16, 64, 255]" ≅ [255 * 0.25², 255 * 0.5², 255 * 1²]. print(buffer.array)

## See Also

### Applying gamma

- [applyGamma(_:intermediateBuffer:destination:)](accelerate/vimage/pixelbuffer/applygamma(_:intermediatebuffer:destination:)-1fif9.md)
- [applyGamma(_:intermediateBuffer:destination:)](accelerate/vimage/pixelbuffer/applygamma(_:intermediatebuffer:destination:)-390k5.md)
- [applyGamma(_:intermediateBuffer:destination:)](accelerate/vimage/pixelbuffer/applygamma(_:intermediatebuffer:destination:)-wsww.md)
- [applyGamma(_:destination:)](accelerate/vimage/pixelbuffer/applygamma(_:destination:).md)
- [vImage.Gamma](accelerate/vimage/gamma.md)
