MagickCore, C API: Image Histograms @ ImageMagick
Author: ImageMagick Studio LLC
Description: ImageMagick® is a software suite to create, edit, compose, or convert bitmap images. It can read and write images in a variety of formats (over 200) including PNG, JPEG, JPEG-2000, GIF, WebP, Postscript, PDF, and SVG. Use ImageMagick to resize, flip, mirror, rotate, distort, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bézier curves.
Keywords: magickcore, c, api:, image, histograms, ImageMagick, PerlMagick, image processing, image, photo, software, Magick++, OpenMP, convert

GetImageHistogram • IdentifyPaletteImage • IsHistogramImage • IsPaletteImage • MinMaxStretchImage • GetNumberColors • UniqueImageColors

## GetImageHistogram

GetImageHistogram() returns the unique colors in an image.

The format of the GetImageHistogram method is:

    size_t GetImageHistogram(const Image *image,
      size_t *number_colors,ExceptionInfo *exception)

A description of each parameter follows.

image

the image.

file

Write a histogram of the color distribution to this file handle.

exception

return any errors or warnings in this structure.

## IdentifyPaletteImage

IdentifyPaletteImage() returns MagickTrue if the image has 256 unique colors or less.

The format of the IdentifyPaletteImage method is:

    MagickBooleanType IdentifyPaletteImage(const Image *image,
      ExceptionInfo *exception)

A description of each parameter follows.

image

the image.

exception

return any errors or warnings in this structure.

## IsHistogramImage

IsHistogramImage() returns MagickTrue if the image has 1024 unique colors or less.

The format of the IsHistogramImage method is:

    MagickBooleanType IsHistogramImage(const Image *image,
      ExceptionInfo *exception)

A description of each parameter follows.

image

the image.

exception

return any errors or warnings in this structure.

## IsPaletteImage

IsPaletteImage() returns MagickTrue if the image is PseudoClass and has 256 unique colors or less.

The format of the IsPaletteImage method is:

    MagickBooleanType IsPaletteImage(const Image *image,
      ExceptionInfo *exception)

A description of each parameter follows.

image

the image.

exception

return any errors or warnings in this structure.

## MinMaxStretchImage

MinMaxStretchImage() uses the exact minimum and maximum values found in each of the channels given, as the BlackPoint and WhitePoint to linearly stretch the colors (and histogram) of the image. The stretch points are also moved further inward by the adjustment values given.

If the adjustment values are both zero this function is equivalent to a perfect normalization (or autolevel) of the image.

Each channel is stretched independantally of each other (producing color distortion) unless the special 'SyncChannels' flag is also provided in the channels setting. If this flag is present the minimum and maximum point will be extracted from all the given channels, and those channels will be stretched by exactly the same amount (preventing color distortion).

In the special case that only ONE value is found in a channel of the image that value is not stretched, that value is left as is.

The 'SyncChannels' is turned on in the 'DefaultChannels' setting by default.

The format of the MinMaxStretchImage method is:

    MagickBooleanType MinMaxStretchImage(Image *image,
      const ChannelType channel, const double black_adjust,
      const double white_adjust)

A description of each parameter follows:

image
  The image to auto-level
channel
  The channels to auto-level. If the special 'SyncChannels' flag is set, all the given channels are stretched by the same amount.
black_adjust, white_adjust
  Move the Black/White Point inward from the minimum and maximum points by this color value.

## GetNumberColors

GetNumberColors() returns the number of unique colors in an image.

The format of the GetNumberColors method is:

    size_t GetNumberColors(const Image *image,FILE *file,
      ExceptionInfo *exception)

A description of each parameter follows.

image

the image.

file

Write a histogram of the color distribution to this file handle.

exception

return any errors or warnings in this structure.

## UniqueImageColors

UniqueImageColors() returns the unique colors of an image.

The format of the UniqueImageColors method is:

    Image *UniqueImageColors(const Image *image,ExceptionInfo *exception)

A description of each parameter follows.

image

the image.

exception

return any errors or warnings in this structure.