<!--
{
  "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/PixelBuffer/applyGamma(_:intermediateBuffer:destination:)-1fif9",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Accelerate"
    ],
    "preciseIdentifier" : "s:10Accelerate6vImageO11PixelBufferVAaC7Planar8VRszrlE10applyGamma_012intermediateD011destinationyAC0G0O_AEy_AC7PlanarFVGSgAEy_AGGtF"
  },
  "title" : "applyGamma(_:intermediateBuffer:destination:)"
}
-->

# applyGamma(_:intermediateBuffer:destination:)

Applies a gamma function to an 8-bit planar pixel buffer.

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

## Parameters

`gamma`

An enumeration that specifies either a used-defined or constant gamma.

`intermediateBuffer`

An optional intermediate buffer.

`destination`

The destination pixel buffer.

## Discussion

This operation applies gamma to an [`vImage.Planar8`](/documentation/Accelerate/vImage/Planar8) buffer by calling the underlying function [`vImageGamma_Planar8toPlanarF(_:_:_:_:)`](/documentation/Accelerate/vImageGamma_Planar8toPlanarF(_:_:_:_:)). Therefore, it requires an intermediate [`vImage.PlanarF`](/documentation/Accelerate/vImage/PlanarF) buffer. For the best performance, pass an existing [`vImage.PlanarF`](/documentation/Accelerate/vImage/PlanarF) 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:

```swift
let buffer = vImage.PixelBuffer<vImage.Planar8>(
    pixelValues: [128],
    size: vImage.Size(width: 1,
                      height: 1))

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

// Prints "[64]" ≅ [255 * 0.5²].
print(buffer.array)
```

---

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)