MPSImageHistogramSpecification(3)

NAME
MPSImageHistogramSpecification

SYNOPSIS

#import <MPSImageHistogram.h>

Inherits MPSUnaryImageKernel.

  Instance Methods
(nonnull instancetype) - initWithDevice:histogramInfo:
(nullable instancetype) - initWithCoder:device:
(void) - encodeTransformToCommandBuffer:sourceTexture:sourceHistogram:sourceHistogramOffset:desiredHistogram:desiredHistogramOffset:

  Properties
MPSImageHistogramInfo histogramInfo

  Additional Inherited Members

Detailed Description

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

Method Documentation

  - (void) encodeTransformToCommandBuffer: (nonnull id< MTLCommandBuffer >) commandBuffer(nonnull id< MTLTexture >) source(nonnull id< MTLBuffer >) sourceHistogram(NSUInteger) sourceHistogramOffset(nonnull id< MTLBuffer >) desiredHistogram(NSUInteger) desiredHistogramOffset
Encode the transform function to a command buffer using a MTLComputeCommandEncoder. The transform function computes the specification lookup table. The transform function will not begin to execute until after the command buffer has been enqueued and committed. This step will need to be repeated with the new MPSKernel if -copyWithZone:device or -copyWithZone: is called.

Parameters:
    commandBuffer A valid MTLCommandBuffer.
    source A valid MTLTexture containing the source image for the filter.
    sourceHistogram A valid MTLBuffer containing the histogram results for the source image. This filter will use these histogram results to generate the cumulative histogram for equalizing the image. The histogram results / channel are stored together. The number of channels for which histogram results are stored is determined by the number of channels in the image. If histogramInfo.histogramForAlpha is false and the source image is RGBA then only histogram results for RGB channels are stored.
    sourceHistogramOffset A byte offset into the sourceHistogram MTLBuffer where the histogram starts. Must conform to alignment requirements for [MTLComputeCommandEncoder setBuffer:offset:atIndex:] offset parameter.
    desiredHistogram A valid MTLBuffer containing the desired histogram results for the source image. The histogram results / channel are stored together. The number of channels for which histogram results are stored is determined by the number of channels in the image. If histogramInfo.histogramForAlpha is false and the source image is RGBA then only histogram results for RGB channels are stored.
    desiredHistogramOffset A byte offset into the desiredHistogram MTLBuffer where the histogram starts. Must conform to alignment requirements for [MTLComputeCommandEncoder setBuffer:offset:atIndex:] offset parameter.

  - (nullable instancetype) initWithCoder: (NSCoder *__nonnull) aDecoder(nonnull id< MTLDevice >) device
NSSecureCoding compatability While the standard NSSecureCoding/NSCoding method -initWithCoder: should work, since the file can't know which device your data is allocated on, we have to guess and may guess incorrectly. To avoid that problem, use initWithCoder:device instead.

Parameters:
    aDecoder The NSCoder subclass with your serialized MPSKernel
    device The MTLDevice on which to make the MPSKernel

Returns:
    A new MPSKernel object, or nil if failure.

Reimplemented from MPSUnaryImageKernel.

  - (nonnull instancetype) initWithDevice: (nonnull id< MTLDevice >) device(const MPSImageHistogramInfo *__nonnull) histogramInfo
Specifies information about the histogram for the channels of an image. The MPSImageHistogramSpecification applies a transfor to convert the histogram to a specified histogram. The process is divided into three steps:

1.  Call -initWithDevice:histogramInfo: This creates a MPSImageHistogramSpecification object. It is done when the method returns.

2.  Call -encodeTransform:sourceTexture:sourceHistogram:sourceHistogramOffset:desiredHistogram: desiredHistogramOffset: This creates a privately held image transform which will convert the the distribution of the source histogram to the desired histogram. This process runs on a MTLCommandBuffer when it is committed to a MTLCommandQueue. It must complete before the next step can be run. It may be performed on the same MTLCommandBuffer. The sourceTexture argument is used by encodeTransform to determine the number of channels and therefore which histogram data in sourceHistogram buffer to use. The sourceHistogram and desiredHistogram must have been computed either on the CPU or using the MPSImageHistogram kernel

3.  Call -encodeToCommandBuffer:sourceTexture:destinationTexture: to read data from sourceTexture, apply the transform to it and write to destination texture. This step is also done on the GPU on a MTLCommandQueue.

You can reuse the same specification transform on other images to perform the same transform on those images. (Since their starting distribution is probably different, they will probably not arrive at the same distribution as the desired histogram.) This filter usually will not be able to work in place.

Parameters:
    device The device the filter will run on
    histogramInfo Pointer to the MPSHistogramInfo struct

Returns:
    A valid MPSImageHistogramSpecification object or nil, if failure.

Property Documentation

  - histogramInfo [read], [nonatomic], [assign]
Return a structure describing the histogram content Returns a MPSImageHistogramInfo structure describing the format of the histogram.

Author

Generated automatically by Doxygen for MetalPerformanceShaders.framework from the source code.