Contents

histogramDisplay()

Generates a histogram map from the image.

Declaration

class func histogramDisplay() -> any CIFilter & CIHistogramDisplay

Return Value

The generated image.

Discussion

This method applies the histogram display filter to the result of the output from the areaHistogram() filter. This effect shows a graphical representation of the tonal distribution of colors in the image.

The histogram display filter uses the following properties:

inputImage

An image with the type CIImage. Typically this is the output from the area histogram filter.

height

A float representing the height of the generated histogram image as an NSNumber.

lowLimit

A float representing the fraction of the left portion of the histogram image to make darker as an NSNumber.

hightLimit

A float representing the fraction of the right portion of the histogram to make lighter as an NSNumber.

The following code creates a filter that results in a histogram diagram generated from the input image:

func areaHistogram(inputImage: CIImage) -> CIImage {
    let filter = CIFilter.areaHistogram()
    filter.inputImage = inputImage
    filter.count = 256
    filter.scale = 50
    filter.extent = CGRect(
        x: inputImage.extent.width/2-250,
        y: inputImage.extent.height/2-250,
        width: 500,
        height: 500)
    return filter.outputImage!
}

func histogramDisplay(inputImage: CIImage) -> CIImage {
    let filter = CIFilter.histogramDisplay()
    filter.inputImage = areaHistogram(inputImage: inputImage)
    filter.highLimit = 1
    filter.height = 100
    filter.lowLimit = 0
    return filter.outputImage!
}

[Image]

See Also

Filters