Histogram

Calculate and or manipulate an image's histogram.

Overview

Histogram functions calculate image histograms or manipulate a histogram to modify an image. There are a number of reasons to apply histogram operations to an image. An image may not make full use of the possible range of intensity values—for example, most of its pixels may be fairly dark, making details difficult to see. Changing the image so that it has a more uniform histogram can improve contrast. Also, it may be easier to compare two images (with respect to texture or other aspects) if you change each histogram to match some standard histogram.

Histogram operations are point operations: that is, the intensity of a destination pixel depends only on the intensity of the source pixel, modified by values that are the same over the entire image. Two pixels of the same intensity always map to two pixels of the same (but presumably altered) intensity. If the original image has N different intensity values, the transformed image will have at most N different intensity levels represented.

The vImage histogram functions either calculate histograms or perform one of these point operations:

  • Contrast stretch transforms an image so that its intensity values stretch out along the full range of intensity values. It is best used on images in which all the pixels are concentrated in one area of the intensity spectrum, and intensity values outside that area are not represented.

  • Ends-in contrast stretch is a more complex version of the contrast stretch operation. These types of functions are best used on images that have some pixels at or near the lowest and highest values of the intensity spectrum, but whose histogram is still mainly concentrated in one area. The ends-in contrast stretch functions map all intensities less than or equal to a certain level to 0; all intensities greater than or equal to a certain level to 255; and perform a contrast stretch on all the values in between. The low and high levels are not defined directly by two given intensity values, but by percentages: the ends-in contrast stretch operation must find intensity levels such that a certain percent of pixels are below one of the intensity values, and a certain percent are above the other intensity value

  • Equalization transforms an image so that it has a more uniform histogram. A truly uniform histogram is one in which each intensity level occurs with equal frequency. These functions approximate that histogram.

  • Histogram specification transforms an image so that its histogram more closely resembles a given histogram.

Topics

Stretching the Contrast

vImageContrastStretch_ARGBFFFF

Stretches the contrast of an ARGBFFFF source image.

vImageContrastStretch_ARGB8888

Stretches the contrast of an ARGB8888 source image.

vImageContrastStretch_PlanarF

Stretches the contrast of a PlanarF source image.

vImageContrastStretch_Planar8

Stretches the contrast of a Planar8 source image.

vImageEndsInContrastStretch_ARGBFFFF

Performs an ends-in contrast stretch operation on an ARGBFFFF source image.

vImageEndsInContrastStretch_ARGB8888

Performs an ends-in contrast stretch operation on an ARGB8888 source image.

vImageEndsInContrastStretch_PlanarF

Performs an ends-in contrast stretch operation on a PlanarF source image.

vImageEndsInContrastStretch_Planar8

Performs an ends-in contrast stretch operation on a Planar8 source image.

Equalizing a Histogram

vImageEqualization_ARGBFFFF

Equalizes the histogram of an ARGBFFFF source image.

vImageEqualization_ARGB8888

Equalizes the histogram of an ARGB8888 source image.

vImageEqualization_PlanarF

Equalizes the histogram of a PlanarF source image.

vImageEqualization_Planar8

Equalizes the histogram of an ARGB8888 source image.

Specifying a Histogram

vImageHistogramSpecification_ARGBFFFF

Performs a histogram specification operation on an ARGBFFFF source image.

vImageHistogramSpecification_ARGB8888

Performs a histogram specification operation on an ARGB8888 source image.

vImageHistogramSpecification_PlanarF

Performs a histogram specification operation on a PlanarF source image.

vImageHistogramSpecification_Planar8

Performs a histogram specification operation on a Planar8 source image.

Calculating a Histogram

vImageHistogramCalculation_ARGBFFFF

Calculates histograms for each channel of an ARGBFFFF image.

vImageHistogramCalculation_ARGB8888

Calculates histograms for each channel of an ARGB8888 image.

vImageHistogramCalculation_PlanarF

Calculates the histogram a PlanarF image.

vImageHistogramCalculation_Planar8

Calculates a histogram for a Planar8 image.

Querying the Minimum Buffer Size

vImageGetMinimumTempBufferSizeForHistogram

Returns the minimum size, in bytes, for the temporary buffer needed by a histogram function.

See Also

Color and Tone Adjustment

Adjusting the Brightness and Contrast of an Image

Use a gamma function to apply a linear or exponential curve.

Specifying Histograms with vImage

Calculate the histogram of one image and apply it to a second image.

Transform

Apply color transformations to images.