<!--
{
  "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(linearParameters:exponentialParameters:boundary:destination:)-8r0ro",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Accelerate"
    ],
    "preciseIdentifier" : "s:10Accelerate6vImageO11PixelBufferVA2A06StaticC6FormatRzSf13ComponentTypeRtzrlE10applyGamma16linearParameters011exponentialL08boundary11destinationySf5scale_Sf4biast_SfAN_Sf7preBiasSf5gammaSf04postS0tSfAEy_xGtF"
  },
  "title" : "applyGamma(linearParameters:exponentialParameters:boundary:destination:)"
}
-->

# applyGamma(linearParameters:exponentialParameters:boundary:destination:)

Applies a piecewise gamma calculation to a 32-bit pixel buffer.

```
func applyGamma(linearParameters: (scale: Float, bias: Float), exponentialParameters: (scale: Float, preBias: Float, gamma: Float, postBias: Float), boundary: Float, destination: vImage.PixelBuffer<Format>)
```

## Parameters

`linearParameters`

The scale and bias applied to pixels with a value below `boundary`.

`exponentialParameters`

The boundary value that defines whether the function transforms pixels with the linear or the exponential calculation.

`boundary`

The parameters that the function uses for the exponential calculation.

`destination`

The destination pixel buffer.

## Discussion

This function computes the output value of each pixel using the following pseudocode:

```swift
For each source pixel value x:
 if x < boundary:
     scale = linearParameters.scale
     bias = linearParameters.bias

     r = x * scale + bias
 else:
     scale = exponentialParameters.scale
     preBias = exponentialParameters.preBias
     gamma = exponentialParameters.gamma
     postBias = exponentialParameters.postBias

     t = x * scale + preBias
     r = pow(t, gamma) + postBias
 output pixel value = r
```

For example, the following code applies piecewise gamma to a one-pixel, two-channel pixel buffer.

The first channel’s value is below the boundary and the second channel’s value is above the boundary.

The operation mutliplies the first channel’s value by two and squares the second channel’s value.

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

buffer.applyGamma(linearParameters: (scale: 2,
                                     bias: 0),
                  exponentialParameters: (scale: 1,
                                          preBias: 0,
                                          gamma: 2,
                                          postBias: 0),
                  boundary: 0.5,
                  destination: buffer)

// Prints "[0.5, 0.5625]" = [ 0.25 * 2, 0.75² ].
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)