<!--
{
  "documentType" : "article",
  "framework" : "Accelerate",
  "identifier" : "/documentation/Accelerate/calculating-and-transforming-histograms",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "Calculating and transforming histograms"
}
-->

# Calculating and transforming histograms

Enhance and adjust the contrast of an image with histogram equalization, contrast stretching, and specification.

## Topics

### Contrast stretching

[`func contrastStretch(destination: vImage.PixelBuffer<vImage.Planar8>)`](/documentation/Accelerate/vImage/PixelBuffer/contrastStretch(destination:)-6usbh)

Stretches the histogram of an 8-bit planar pixel buffer.

[`func contrastStretch(binCount: Int, destination: vImage.PixelBuffer<vImage.PlanarF>)`](/documentation/Accelerate/vImage/PixelBuffer/contrastStretch(binCount:destination:)-3bo13)

Stretches the histogram of a 32-bit planar pixel buffer.

[`func contrastStretch(destination: vImage.PixelBuffer<vImage.Interleaved8x4>)`](/documentation/Accelerate/vImage/PixelBuffer/contrastStretch(destination:)-7zo9)

Stretches the histogram of an 8-bit-per-channel, 4-channel interleaved pixel buffer.

[`func contrastStretch(binCount: Int, destination: vImage.PixelBuffer<vImage.InterleavedFx4>)`](/documentation/Accelerate/vImage/PixelBuffer/contrastStretch(binCount:destination:)-704t6)

Stretches the histogram of a 32-bit-per-channel, 4-channel interleaved pixel buffer.

[`func contrastStretch(destination: vImage.PixelBuffer<Format>)`](/documentation/Accelerate/vImage/PixelBuffer/contrastStretch(destination:)-2nsx9)

Stretches the histogram of a multiple-plane 8-bit pixel buffer.

[`func contrastStretch(binCount: Int, destination: vImage.PixelBuffer<Format>)`](/documentation/Accelerate/vImage/PixelBuffer/contrastStretch(binCount:destination:)-81vq2)

Stretches the histogram of a multiple-plane 32-bit pixel buffer.

### Equalization

[`func equalizeHistogram(destination: vImage.PixelBuffer<vImage.Planar8>)`](/documentation/Accelerate/vImage/PixelBuffer/equalizeHistogram(destination:)-7temg)

Equalizes the histogram of an 8-bit planar pixel buffer.

[`func equalizeHistogram(binCount: Int, destination: vImage.PixelBuffer<vImage.PlanarF>)`](/documentation/Accelerate/vImage/PixelBuffer/equalizeHistogram(binCount:destination:)-5iv0q)

Equalizes the histogram of a 32-bit planar pixel buffer.

[`func equalizeHistogram(destination: vImage.PixelBuffer<Format>)`](/documentation/Accelerate/vImage/PixelBuffer/equalizeHistogram(destination:)-2gbmf)

Equalizes the histogram of an 8-bit-per-channel, 4-channel interleaved pixel buffer.

[`func equalizeHistogram(binCount: Int, destination: vImage.PixelBuffer<vImage.InterleavedFx4>)`](/documentation/Accelerate/vImage/PixelBuffer/equalizeHistogram(binCount:destination:)-6on8w)

Equalizes the histogram of a 32-bit-per-channel, 4-channel interleaved pixel buffer.

[`func equalizeHistogram(destination: vImage.PixelBuffer<Format>)`](/documentation/Accelerate/vImage/PixelBuffer/equalizeHistogram(destination:)-939xn)

Equalizes the histogram of a multiple-plane 8-bit pixel buffer.

[`func equalizeHistogram(binCount: Int, destination: vImage.PixelBuffer<Format>)`](/documentation/Accelerate/vImage/PixelBuffer/equalizeHistogram(binCount:destination:)-59li2)

Equalizes the histogram of a multiple-plane 32-bit pixel buffer.

### Histogram calculation

[`func histogram() -> vImage.PixelBuffer<Format>.Histogram8888`](/documentation/Accelerate/vImage/PixelBuffer/histogram()-14a38)

Calculates the histogram of an 8-bit-per-channel, 4-channel interleaved pixel buffer.

[`func histogram(binCount: Int) -> vImage.PixelBuffer<Format>.HistogramFFFF`](/documentation/Accelerate/vImage/PixelBuffer/histogram(binCount:)-6pkfv)

Calculates the histogram of a 32-bit-per-channel, 4-channel interleaved pixel buffer.

[`func histogram() -> vImage.PixelBuffer<Format>.Histogram888`](/documentation/Accelerate/vImage/PixelBuffer/histogram()-30tsp)

Calculates the histogram of an 8-bit-per-channel, 3-channel multiple-plane pixel buffer.

[`func histogram(binCount: Int) -> vImage.PixelBuffer<Format>.HistogramFFF`](/documentation/Accelerate/vImage/PixelBuffer/histogram(binCount:)-8wymg)

Calculates the histogram of a 32-bit-per-channel, 3-channel multiple-plane pixel buffer.

[`func histogram() -> vImage.PixelBuffer<Format>.Histogram8888`](/documentation/Accelerate/vImage/PixelBuffer/histogram()-6wxl5)

Calculates the histogram of an 8-bit-per-channel, 4-channel multiple-plane pixel buffer.

[`func histogram(binCount: Int) -> vImage.PixelBuffer<Format>.HistogramFFFF`](/documentation/Accelerate/vImage/PixelBuffer/histogram(binCount:)-5bqka)

Calculates the histogram of a 32-bit-per-channel, 4-channel multiple-plane pixel buffer.

### Histogram specification

[`func specifyHistogram(vImage.PixelBuffer<Format>.Histogram8888, destination: vImage.PixelBuffer<Format>)`](/documentation/Accelerate/vImage/PixelBuffer/specifyHistogram(_:destination:)-7xiz4)

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

[`func specifyHistogram(vImage.PixelBuffer<Format>.HistogramFFFF, destination: vImage.PixelBuffer<Format>)`](/documentation/Accelerate/vImage/PixelBuffer/specifyHistogram(_:destination:)-1x46n)

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

[`func specifyHistogram(vImage.PixelBuffer<Format>.Histogram888, destination: vImage.PixelBuffer<Format>)`](/documentation/Accelerate/vImage/PixelBuffer/specifyHistogram(_:destination:)-qeqr)

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

[`func specifyHistogram(vImage.PixelBuffer<Format>.HistogramFFF, destination: vImage.PixelBuffer<Format>)`](/documentation/Accelerate/vImage/PixelBuffer/specifyHistogram(_:destination:)-28844)

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

[`func specifyHistogram(vImage.PixelBuffer<Format>.Histogram8888, destination: vImage.PixelBuffer<Format>)`](/documentation/Accelerate/vImage/PixelBuffer/specifyHistogram(_:destination:)-73dpr)

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

[`func specifyHistogram(vImage.PixelBuffer<Format>.HistogramFFFF, destination: vImage.PixelBuffer<Format>)`](/documentation/Accelerate/vImage/PixelBuffer/specifyHistogram(_:destination:)-7cvk1)

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

### Type aliases

[`typealias Histogram888`](/documentation/Accelerate/vImage/PixelBuffer/Histogram888)

The histogram for three channel 8-bit pixel buffers.

[`typealias Histogram8888`](/documentation/Accelerate/vImage/PixelBuffer/Histogram8888)

The histogram for four channel 8-bit pixel buffers.

[`typealias HistogramFFF`](/documentation/Accelerate/vImage/PixelBuffer/HistogramFFF)

The histogram for three channel 32-bit pixel buffers.

[`typealias HistogramFFFF`](/documentation/Accelerate/vImage/PixelBuffer/HistogramFFFF)

The histogram for four channel 32-bit pixel buffers.



---

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)