ImageMagick (legacy) – MagickCore, C API: Image Statistics
Author: ImageMagick Studio LLC
Description: Create, Edit, Compose, or Convert Digital Images
Keywords: magickcore, c, api:, image, statistics, image processing software

EvaluateImage • FunctionImage • GetImageChannelEntropy • GetImageChannelKurtosis • GetImageChannelMean • GetImageChannelMoments • GetImageChannelPerceptualHash • GetImageChannelRange • GetImageChannelStatistics • PolynomialImage • StatisticImage

## EvaluateImage

EvaluateImage() applies a value to the image with an arithmetic, relational, or logical operator to an image. Use these operations to lighten or darken an image, to increase or decrease contrast in an image, or to produce the "negative" of an image.

The format of the EvaluateImageChannel method is:

    MagickBooleanType EvaluateImage(Image *image,
      const MagickEvaluateOperator op,const double value,
      ExceptionInfo *exception)
    MagickBooleanType EvaluateImages(Image *images,
      const MagickEvaluateOperator op,const double value,
      ExceptionInfo *exception)
    MagickBooleanType EvaluateImageChannel(Image *image,
      const ChannelType channel,const MagickEvaluateOperator op,
      const double value,ExceptionInfo *exception)

A description of each parameter follows:

image
  the image.
channel
  the channel.
op
  A channel op.
value
  A value value.
exception
  return any errors or warnings in this structure.

## FunctionImage

FunctionImage() applies a value to the image with an arithmetic, relational, or logical operator to an image. Use these operations to lighten or darken an image, to increase or decrease contrast in an image, or to produce the "negative" of an image.

The format of the FunctionImageChannel method is:

    MagickBooleanType FunctionImage(Image *image,
      const MagickFunction function,const ssize_t number_parameters,
      const double *parameters,ExceptionInfo *exception)
    MagickBooleanType FunctionImageChannel(Image *image,
      const ChannelType channel,const MagickFunction function,
      const ssize_t number_parameters,const double *argument,
      ExceptionInfo *exception)

A description of each parameter follows:

image
  the image.
channel
  the channel.
function
  A channel function.
parameters
  one or more parameters.
exception
  return any errors or warnings in this structure.

## GetImageChannelEntropy

GetImageChannelEntropy() returns the entropy of one or more image channels.

The format of the GetImageChannelEntropy method is:

    MagickBooleanType GetImageChannelEntropy(const Image *image,
      const ChannelType channel,double *entropy,ExceptionInfo *exception)

A description of each parameter follows:

image
  the image.
channel
  the channel.
entropy
  the average entropy of the selected channels.
exception
  return any errors or warnings in this structure.

## GetImageChannelKurtosis

GetImageChannelKurtosis() returns the kurtosis and skewness of one or more image channels.

The format of the GetImageChannelKurtosis method is:

    MagickBooleanType GetImageChannelKurtosis(const Image *image,
      const ChannelType channel,double *kurtosis,double *skewness,
      ExceptionInfo *exception)

A description of each parameter follows:

image
  the image.
channel
  the channel.
kurtosis
  the kurtosis of the channel.
skewness
  the skewness of the channel.
exception
  return any errors or warnings in this structure.

## GetImageChannelMean

GetImageChannelMean() returns the mean and standard deviation of one or more image channels.

The format of the GetImageChannelMean method is:

    MagickBooleanType GetImageChannelMean(const Image *image,
      const ChannelType channel,double *mean,double *standard_deviation,
      ExceptionInfo *exception)

A description of each parameter follows:

image
  the image.
channel
  the channel.
mean
  the average value in the channel.
standard_deviation
  the standard deviation of the channel.
exception
  return any errors or warnings in this structure.

## GetImageChannelMoments

GetImageChannelMoments() returns the normalized moments of one or more image channels.

The format of the GetImageChannelMoments method is:

    ChannelMoments *GetImageChannelMoments(const Image *image,
      ExceptionInfo *exception)

A description of each parameter follows:

image
  the image.
exception
  return any errors or warnings in this structure.

## GetImageChannelPerceptualHash

GetImageChannelPerceptualHash() returns the perceptual hash of one or more image channels.

The format of the GetImageChannelPerceptualHash method is:

    ChannelPerceptualHash *GetImageChannelPerceptualHash(const Image *image,
      ExceptionInfo *exception)

A description of each parameter follows:

image
  the image.
exception
  return any errors or warnings in this structure.

## GetImageChannelRange

GetImageChannelRange() returns the range of one or more image channels.

The format of the GetImageChannelRange method is:

    MagickBooleanType GetImageChannelRange(const Image *image,
      const ChannelType channel,double *minima,double *maxima,
      ExceptionInfo *exception)

A description of each parameter follows:

image
  the image.
channel
  the channel.
minima
  the minimum value in the channel.
maxima
  the maximum value in the channel.
exception
  return any errors or warnings in this structure.

## GetImageChannelStatistics

GetImageChannelStatistics() returns statistics for each channel in the image. The statistics include the channel depth, its minima, maxima, mean, standard deviation, kurtosis and skewness. You can access the red channel mean, for example, like this:

    channel_statistics=GetImageChannelStatistics(image,exception);
    red_mean=channel_statistics[RedChannel].mean;

Use MagickRelinquishMemory() to free the statistics buffer.

The format of the GetImageChannelStatistics method is:

    ChannelStatistics *GetImageChannelStatistics(const Image *image,
      ExceptionInfo *exception)

A description of each parameter follows:

image
  the image.
exception
  return any errors or warnings in this structure.

## PolynomialImage

PolynomialImage() returns a new image where each pixel is the sum of the pixels in the image sequence after applying its corresponding terms (coefficient and degree pairs).

The format of the PolynomialImage method is:

    Image *PolynomialImage(const Image *images,const size_t number_terms,
      const double *terms,ExceptionInfo *exception)
    Image *PolynomialImageChannel(const Image *images,
      const size_t number_terms,const ChannelType channel,
      const double *terms,ExceptionInfo *exception)

A description of each parameter follows:

images
  the image sequence.
channel
  the channel.
number_terms
  the number of terms in the list. The actual list length is 2 x number_terms + 1 (the constant).
terms
  the list of polynomial coefficients and degree pairs and a constant.
exception
  return any errors or warnings in this structure.

## StatisticImage

StatisticImage() makes each pixel the min / max / median / mode / etc. of the neighborhood of the specified width and height.

The format of the StatisticImage method is:

    Image *StatisticImage(const Image *image,const StatisticType type,
      const size_t width,const size_t height,ExceptionInfo *exception)
    Image *StatisticImageChannel(const Image *image,
      const ChannelType channel,const StatisticType type,
      const size_t width,const size_t height,ExceptionInfo *exception)

A description of each parameter follows:

image
  the image.
channel
  the image channel.
type
  the statistic type (median, mode, etc.).
width
  the width of the pixel neighborhood.
height
  the height of the pixel neighborhood.
exception
  return any errors or warnings in this structure.