GraphicsMagick Search site

- Home
- License
- Mission
- Download
- Installation
- FAQ
- News
- Formats

- Process
- Contribute
- CVS
- Mailing Lists
- ChangeLog
- Report Bugs
- Utilities
- Programming
- Links

# quantize

## Reduce the number of colors in an image

Contents

- CloneQuantizeInfo
- CompressImageColormap
- DestroyQuantizeInfo
- GetImageQuantizeError
- GetQuantizeInfo
- GrayscalePseudoClassImage
- MapImage
- MapImages
- OrderedDitherImage
- QuantizeImage
- QuantizeImages

# CloneQuantizeInfo

## Synopsis

    QuantizeInfo *CloneQuantizeInfo( const QuantizeInfo *quantize_info );

## Description

CloneQuantizeInfo() makes a duplicate of the given quantize info structure, or if quantize info is NULL, a new one.

The format of the CloneQuantizeInfo method is:

    QuantizeInfo *CloneQuantizeInfo( const QuantizeInfo *quantize_info );

A description of each parameter follows:

clone_info:
  Method CloneQuantizeInfo returns a duplicate of the given quantize info, or if image info is NULL a new one.
quantize_info:
  a structure of type info.

# CompressImageColormap

## Synopsis

    void CompressImageColormap( Image *image );

## Description

CompressImageColormap() compresses an image colormap by removing any duplicate or unused color entries.

The format of the CompressImageColormap method is:

    void CompressImageColormap( Image *image );

A description of each parameter follows:

image:
  The image.

# DestroyQuantizeInfo

## Synopsis

    DestroyQuantizeInfo( QuantizeInfo *quantize_info );

## Description

DestroyQuantizeInfo() deallocates memory associated with an QuantizeInfo structure.

The format of the DestroyQuantizeInfo method is:

    DestroyQuantizeInfo( QuantizeInfo *quantize_info );

A description of each parameter follows:

quantize_info:
  Specifies a pointer to an QuantizeInfo structure.

# GetImageQuantizeError

## Synopsis

    unsigned int GetImageQuantizeError( Image *image );

## Description

GetImageQuantizeError() measures the difference between the original and quantized images. This difference is the total quantization error. The error is computed by summing over all pixels in an image the distance squared in RGB space between each reference pixel value and its quantized value. These values are computed:

o mean_error_per_pixel: This value is the mean error for any single pixel in the image.

o normalized_mean_square_error: This value is the normalized mean quantization error for any single pixel in the image. This distance measure is normalized to a range between 0 and 1. It is independent of the range of red, green, and blue values in the image.

o normalized_maximum_square_error: Thsi value is the normalized maximum quantization error for any single pixel in the image. This distance measure is normalized to a range between 0 and 1. It is independent of the range of red, green, and blue values in your image.

The format of the GetImageQuantizeError method is:

    unsigned int GetImageQuantizeError( Image *image );

A description of each parameter follows.

image:
  Specifies a pointer to an Image structure; returned from ReadImage.

# GetQuantizeInfo

## Synopsis

    GetQuantizeInfo( QuantizeInfo *quantize_info );

## Description

GetQuantizeInfo() initializes the QuantizeInfo structure.

The format of the GetQuantizeInfo method is:

    GetQuantizeInfo( QuantizeInfo *quantize_info );

A description of each parameter follows:

quantize_info:
  Specifies a pointer to a QuantizeInfo structure.

# GrayscalePseudoClassImage

## Synopsis

    void GrayscalePseudoClassImage( Image *image );

## Description

GrayscalePseudoClassImage converts an image to a PseudoClass grayscale representation with an (optionally) compressed and sorted colormap. Colormap is ordered by increasing intensity.

The format of the GrayscalePseudoClassImage method is:

    void GrayscalePseudoClassImage( Image *image );

A description of each parameter follows:

image:
  The image.
optimize_colormap:
  If true, produce an optimimal (compact) colormap.

# MapImage

## Synopsis

    unsigned int MapImage( Image *image, const Image *map_image,
                           const unsigned int dither );

## Description

MapImage() replaces the colors of an image with the closest color from a reference image.

The format of the MapImage method is:

    unsigned int MapImage( Image *image, const Image *map_image,
                           const unsigned int dither );

image:
  Specifies a pointer to an Image structure.
map_image:
  Specifies a pointer to an Image structure. Reduce image to a set of colors represented by this image.
dither:
  Set this integer value to something other than zero to dither the quantized image.

# MapImages

## Synopsis

    unsigned int MapImages( Image *images, Image *map_image, const unsigned int dither );

## Description

MapImages() replaces the colors of a sequence of images with the closest color from a reference image. If the reference image does not contain a colormap, then a colormap will be created based on existing colors in the reference image. The order and number of colormap entries does not match the reference image. If the order and number of colormap entries needs to match the reference image, then the ReplaceImageColormap() function may be used after invoking MapImages() in order to apply the reference colormap.

The format of the MapImage method is:

    unsigned int MapImages( Image *images, Image *map_image, const unsigned int dither );

image:
  Specifies a pointer to a set of Image structures.
map_image:
  Specifies a pointer to an Image structure. Reduce image to a set of colors represented by this image.
dither:
  Set this integer value to something other than zero to dither the quantized image.

# OrderedDitherImage

## Synopsis

    unsigned int OrderedDitherImage( Image *image );

## Description

OrderedDitherImage() uses the ordered dithering technique of reducing color images to monochrome using positional information to retain as much information as possible.

The format of the OrderedDitherImage method is:

    unsigned int OrderedDitherImage( Image *image );

A description of each parameter follows.

image:
  Specifies a pointer to an Image structure; returned from ReadImage.

# QuantizeImage

## Synopsis

    unsigned int QuantizeImage( const QuantizeInfo *quantize_info, Image *image );

## Description

QuantizeImage() analyzes the colors within a reference image and chooses a fixed number of colors to represent the image. The goal of the algorithm is to minimize the color difference between the input and output image while minimizing the processing time.

The format of the QuantizeImage method is:

    unsigned int QuantizeImage( const QuantizeInfo *quantize_info, Image *image );

quantize_info:
  Specifies a pointer to an QuantizeInfo structure.
image:
  Specifies a pointer to an Image structure.

# QuantizeImages

## Synopsis

    unsigned int QuantizeImages( const QuantizeInfo *quantize_info, Image *images );

## Description

QuantizeImages() analyzes the colors within a set of reference images and chooses a fixed number of colors to represent the set. The goal of the algorithm is to minimize the color difference between the input and output images while minimizing the processing time.

The format of the QuantizeImages method is:

    unsigned int QuantizeImages( const QuantizeInfo *quantize_info, Image *images );

quantize_info:
  Specifies a pointer to an QuantizeInfo structure.
images:
  Specifies a pointer to a list of Image structures.