<!--
{
  "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/specifyHistogram(_:destination:)-28844",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Accelerate"
    ],
    "preciseIdentifier" : "s:10Accelerate6vImageO11PixelBufferVAaC9PlanarFx3VRszrlE16specifyHistogram_11destinationySi8binCount_SaySuGA2Kt_AEy_AGGtF"
  },
  "title" : "specifyHistogram(_:destination:)"
}
-->

# specifyHistogram(_:destination:)

Performs a histogram specification operation on a 32-bit-per-channel, 3-channel multiple-plane pixel buffer.

```
func specifyHistogram(_ histogram: vImage.PixelBuffer<Format>.HistogramFFF, destination: vImage.PixelBuffer<Format>)
```

## Parameters

`histogram`

The histogram.

`destination`

The destination pixel buffer.

## Discussion

*Histogram specification* is a technique that allows you to calculate the histogram of a reference image and apply it to an input image.

The example below shows a source image (bottom left) and a histogram reference image (top left), with the histogram specification output on the right:

![Photos showing original image, histogram source image, and histogram specified result.](images/com.apple.accelerate/media-3958176@2x.png)

The code below initializes the source and reference buffers from the <doc://com.apple.documentation/documentation/CoreGraphics/CGImage> instances `sourceImage` and `referenceImage` respectively:

```swift
var cgImageFormat = vImage_CGImageFormat(
    bitsPerComponent: 32,
    bitsPerPixel: 32 * 3,
    colorSpace: CGColorSpaceCreateDeviceRGB(),
    bitmapInfo: CGBitmapInfo(rawValue: CGBitmapInfo.byteOrder32Little.rawValue |
                             CGBitmapInfo.floatComponents.rawValue |
                             CGImageAlphaInfo.none.rawValue))!

let interleavedSource = try vImage.PixelBuffer(
    cgImage: sourceImage,
    cgImageFormat: &cgImageFormat,
    pixelFormat: vImage.InterleavedFx3.self)
let multiplePlaneSource = vImage.PixelBuffer<vImage.PlanarFx3>(
    planarBuffers: interleavedSource.planarBuffers())

let interleavedReference = try vImage.PixelBuffer(
    cgImage: referenceImage,
    cgImageFormat: &cgImageFormat,
    pixelFormat: vImage.InterleavedFx3.self)
let multiplePlaneReference = vImage.PixelBuffer<vImage.PlanarFx3>(
    planarBuffers: interleavedReference.planarBuffers())
```

The following code calls [`histogram()`](/documentation/Accelerate/vImage/PixelBuffer/histogram()-14a38) to calculate the histogram of the reference image and passes the histogram to [`specifyHistogram(_:destination:)`](/documentation/Accelerate/vImage/PixelBuffer/specifyHistogram(_:destination:)-7xiz4) to generate the specification result. This function works in place, that is, the input and output can share the same underlying memory.

```swift
let histogram = multiplePlaneReference.histogram(binCount: 1024)

multiplePlaneSource.specifyHistogram(histogram,
                                     destination: multiplePlaneSource)
```

## See Also

  <doc://com.apple.accelerate/documentation/Accelerate/specifying-histograms-with-vimage>



---

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)