<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.13.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MetalPerformanceShaders",
  "identifier" : "/documentation/MetalPerformanceShaders/MPSImageHistogramEqualization",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Metal Performance Shaders"
    ],
    "preciseIdentifier" : "c:objc(cs)MPSImageHistogramEqualization"
  },
  "title" : "MPSImageHistogramEqualization"
}
-->

# MPSImageHistogramEqualization

A filter that equalizes the histogram of an image.

```
class MPSImageHistogramEqualization
```

## Overview

The process is divided into three steps:

1. Call the [`init(device:histogramInfo:)`](/documentation/MetalPerformanceShaders/MPSImageHistogramEqualization/init(device:histogramInfo:)) method to create a [`MPSImageHistogramEqualization`](/documentation/MetalPerformanceShaders/MPSImageHistogramEqualization) object.
2. Call the [`encodeTransform(to:sourceTexture:histogram:histogramOffset:)`](/documentation/MetalPerformanceShaders/MPSImageHistogramEqualization/encodeTransform(to:sourceTexture:histogram:histogramOffset:)) method. This creates a privately held image transform (i.e. a cumulative distribution function of the histogram) which will be used to equalize the distribution of the histogram of the source image. This process runs on a command buffer when it is committed to a command queue. It must complete before the next step can be run. It may be performed on the same command buffer. The `histogram` argument specifies the histogram buffer which contains the histogram values for the source texture. The `sourceTexture` argument is used by the method to determine the number of channels and therefore which histogram data in the histogram buffer to use. The histogram for the source texture must have been computed either on the CPU or using the [`MPSImageHistogram`](/documentation/MetalPerformanceShaders/MPSImageHistogram) kernel.
3. Call the [`encode(commandBuffer:sourceTexture:destinationTexture:)`](/documentation/MetalPerformanceShaders/MPSUnaryImageKernel/encode(commandBuffer:sourceTexture:destinationTexture:)) method to read data from the source texture, apply the equalization transform to it, and write to the destination texture. This step is also done on the GPU on a command queue.

> Note:
> You can reuse the same equalization transform on other images to perform the same transform on those images. (Since their distribution is probably different, they will probably not be equalized by it.) This filter usually will not be able to work in place.

## Topics

### Initializers

[`-  initWithCoder:device:`](/documentation/MetalPerformanceShaders/MPSImageHistogramEqualization/init(coder:device:))

### Methods

[`-  initWithDevice:histogramInfo:`](/documentation/MetalPerformanceShaders/MPSImageHistogramEqualization/init(device:histogramInfo:))

Initializes a histogram with specific information.

[`-  encodeTransformToCommandBuffer:sourceTexture:histogram:histogramOffset:`](/documentation/MetalPerformanceShaders/MPSImageHistogramEqualization/encodeTransform(to:sourceTexture:histogram:histogramOffset:))

Encodes the transform function to a command buffer using a compute command encoder. The transform function computes the equalization lookup table.

### Properties

[`histogramInfo`](/documentation/MetalPerformanceShaders/MPSImageHistogramEqualization/histogramInfo)

A structure describing the histogram content.

## See Also

  [Metal Image Filters: Using the image filters provided by the Metal Performance Shaders framework.](https://developer.apple.com/library/archive/samplecode/MetalImageFilters/Introduction/Intro.html#//apple_ref/doc/uid/TP40017535)

## Relationships

### Conforms To

[`NSCopying`](/documentation/Foundation/NSCopying)

[`Equatable`](/documentation/Swift/Equatable)

[`NSSecureCoding`](/documentation/Foundation/NSSecureCoding)

[`Hashable`](/documentation/Swift/Hashable)

[`NSCoding`](/documentation/Foundation/NSCoding)

[`CVarArg`](/documentation/Swift/CVarArg)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

### Inherits From

[`MPSUnaryImageKernel`](/documentation/MetalPerformanceShaders/MPSUnaryImageKernel)

---

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)