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

# specifyHistogram(_:destination:)

Performs a histogram specification operation on an 8-bit-per-channel, 4-channel interleaved pixel buffer.

## Declaration

```swift
func specifyHistogram(_ histogram: vImage.PixelBuffer<Format>.Histogram8888, 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 * 4,     colorSpace: CGColorSpaceCreateDeviceRGB(),     bitmapInfo: CGBitmapInfo(rawValue: CGImageAlphaInfo.noneSkipFirst.rawValue))!

let sourceBuffer = try vImage.PixelBuffer(     cgImage: sourceImage,     cgImageFormat: &cgImageFormat,     pixelFormat: vImage.Interleaved8x4.self)

let referenceBuffer = try vImage.PixelBuffer(     cgImage: referenceImage,     cgImageFormat: &cgImageFormat,     pixelFormat: vImage.Interleaved8x4.self) 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 = referenceBuffer.histogram()

sourceBuffer.specifyHistogram(histogram,                               destination: sourceBuffer)

## See Also

### Related Documentation

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

### Histogram specification

- [specifyHistogram(_:destination:)](accelerate/vimage/pixelbuffer/specifyhistogram(_:destination:)-1x46n.md)
- [specifyHistogram(_:destination:)](accelerate/vimage/pixelbuffer/specifyhistogram(_:destination:)-qeqr.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)
