<!--
{
  "availability" : [
    "iOS: 26.0.0 -",
    "iPadOS: 26.0.0 -",
    "macCatalyst: 26.0.0 -",
    "macOS: 26.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreImage",
  "identifier" : "/documentation/CoreImage/CIContext/calculateHDRStats(for:)-7bcki",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core Image",
      "CoreImage"
    ],
    "preciseIdentifier" : "c:objc(cs)CIContext(im)calculateHDRStatsForCVPixelBuffer:"
  },
  "title" : "calculateHDRStats(for:)"
}
-->

# calculateHDRStats(for:)

Given a CVPixelBuffer, use the receiving Core Image context to calculate its
HDR statistics (content headroom and content average light level)
and then update the buffer’s attachments to store the values.

```
func calculateHDRStats(for buffer: CVPixelBuffer)
```

## Parameters

`buffer`

A mutable `CVPixelBuffer` for which to calculate and attach statistics.

## Discussion

If the `CVPixelBuffer` has a Clean Aperture rectangle then only pixels within
that rectangle are considered.

---

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)