A filter that performs a histogram specification operation on an image.


@interface MPSImageHistogramSpecification : MPSUnaryImageKernel


MPSImageHistogramSpecification is a generalized version of histogram equalization operation. The histogram specification filter converts the image so that its histogram matches the desired histogram.

The process is divided into three steps:

  1. Call the initWithDevice:histogramInfo: method to create a MPSImageHistogramSpecification object.

  2. Call the encodeTransformToCommandBuffer:sourceTexture:sourceHistogram:sourceHistogramOffset:desiredHistogram:desiredHistogramOffset: method. This creates a privately held image transform which will convert the distribution of the source histogram to the desired histogram. 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 sourceTexture argument is used by the method to determine the number of channels and therefore which histogram data in the source histogram buffer to use. The source histogram and desired histogram must have been computed either on the CPU or using the MPSImageHistogram kernel.

  3. Call the encodeToCommandBuffer: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.



- initWithDevice:histogramInfo:

Initializes a histogram with specific information.

- encodeTransformToCommandBuffer:sourceTexture:sourceHistogram:sourceHistogramOffset:desiredHistogram:desiredHistogramOffset:

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



A structure describing the histogram content.


Inherits From

See Also

Histogram Image Filters


A filter that computes the histogram of an image.


A filter that equalizes the histogram of an image.