---
title: "specifyHistogram(_:destination:)"
framework: accelerate
role: symbol
role_heading: Instance Method
path: "accelerate/vimage/pixelbuffer/specifyhistogram(_:destination:)-qeqr"
---

# specifyHistogram(_:destination:)

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

## Declaration

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

## Parameters

- `histogram`: The histogram.
- `destination`: The destination pixel buffer.

## Discussion

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:

The code below initializes the source and reference buffers from the CGImage instances sourceImage and referenceImage respectively: var cgImageFormat = vImage_CGImageFormat(     bitsPerComponent: 8,     bitsPerPixel: 8 * 3,     colorSpace: CGColorSpaceCreateDeviceRGB(),     bitmapInfo: CGBitmapInfo(rawValue: CGImageAlphaInfo.none.rawValue))!

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

let interleavedReference = try vImage.PixelBuffer(     cgImage: referenceImage,     cgImageFormat: &cgImageFormat,     pixelFormat: vImage.Interleaved8x3.self) let multiplePlaneReference = vImage.PixelBuffer<vImage.Planar8x3>(     planarBuffers: interleavedReference.planarBuffers()) The following code calls histogram() to calculate the histogram of the reference image and passes the histogram to specifyHistogram(_:destination:) to generate the specification result. This function works in place, that is, the input and output can share the same underlying memory. let histogram = multiplePlaneReference.histogram()

multiplePlaneSource.specifyHistogram(histogram,                               destination: multiplePlaneSource)

## See Also

### Related Documentation

- [Specifying histograms with vImage](accelerate/specifying-histograms-with-vimage.md)

### Histogram specification

- [specifyHistogram(_:destination:)](accelerate/vimage/pixelbuffer/specifyhistogram(_:destination:)-7xiz4.md)
- [specifyHistogram(_:destination:)](accelerate/vimage/pixelbuffer/specifyhistogram(_:destination:)-1x46n.md)
- [specifyHistogram(_:destination:)](accelerate/vimage/pixelbuffer/specifyhistogram(_:destination:)-28844.md)
- [specifyHistogram(_:destination:)](accelerate/vimage/pixelbuffer/specifyhistogram(_:destination:)-73dpr.md)
- [specifyHistogram(_:destination:)](accelerate/vimage/pixelbuffer/specifyhistogram(_:destination:)-7cvk1.md)
