ImageGear for C and C++ on Windows v20.0 - Updated
Color Reduction
User Guide > How to Work with ... > Image Processing and Cleanup > Color Reduction

Color reduction in general results in an image with fewer colors than the original, even if the bit depth is not changed. There are a number of color reduction methods, and ImageGear provides several different functions from which you can choose the one that is most suitable in a given case. Below you can see the color reduction methods that are available, and the functions that perform them:

IG_IP_color_reduce_bayer() Reduces a 4, 8, or 24-bit image to a 1-bit or 4-bit image using a Bayer dithering algorithm.
IG_IP_color_reduce_to_bitonal() Reduces a 4, 8, or 24-bit image to a 1-bit or "bi-tonal" image.
IG_IP_color_reduce_median_cut() Reduces a 24-bit image to an 8-bit image using the median cut algorithm.
IG_IP_color_reduce_diffuse() Reduces a 4, 8, or 24-bit image to a 1-bit or 4-bit image using a diffusion algorithm.
IG_IP_color_reduce_popularity() Reduces a 24-bit image to an 8-bit image, while preserving its most prevalent or popular colors.
IG_IP_color_reduce_octree() Reduces a 24-bit or 8-bit image to an 8-bit or 4-bit image. Uses an efficient algorithm that gives a result as close to the original as possible, using the number of colors you specify.
IG_IP_color_reduce_halftone() Reduces a 4, 8, or 24-bit image to a 1-bit image using a halftone pattern.

Refer to the function descriptions in the Core Component API Function Reference for the calling sequences and further information on the above.

The additional function IG_IP_convert_to_gray() is also considered a color reduction function. It is called as follows:

 
Copy Code
IG_IP_convert_to_gray ( hIGear );

It always converts the image to 8-bit gray level. The resulting DIB has a 256-entry palette, and each 8-bit pixel value in the resulting image bitmap is a weighted average of the three color intensities of the pixel in the original image.

The following table lists supported input and output bit depths for color reduction functions:

Function Name Bpp
In
Use or create palette for output image BppOut
IG_IP_color_reduce_bayer() 24 use standard B/W palette 1
8 use standard B/W palette 1
4 use standard B/W palette 1
24 use given palette 4
8 use given palette 4
24 use standard palette 4
8 use standard palette 4
IG_IP_color_reduce_diffuse() 24 use standard B/W palette 1
8 use standard B/W palette 1
4 use standard B/W palette 1
24 use given palette 4
8 use given palette 4
24 use standard palette 4
8 use standard palette 4
IG_IP_color_reduce_halftone() 24 use standard B/W palette 1
8 use standard B/W palette 1
4 use standard B/W palette 1
IG_IP_color_reduce_median_cut() 24 create optimal palette 8
IG_IP_color_reduce_octree() 24 use given palette (maxcolors > 16) 8
8 use given palette (maxcolors > 16) 8
24 create optimal palette (maxcolors > 16) 8
8 create optimal palette (maxcolors > 16) 8
24 use given palette (maxcolors <= 16) 4
8 use given palette (maxcolors <= 16) 4
24 create optimal palette (maxcolors <= 16) 4
8 create optimal palette (maxcolors <= 16) 4
IG_IP_color_reduce_popularity() 24 create optimal palette 8
IG_IP_color_reduce_to_bitonal() 24 use standard B/W palette 1
8 use standard B/W palette 1
4 use standard B/W palette 1
Is this page helpful?
Yes No
Thanks for your feedback.