This unit provides several functions that reduce the number of colors in an image.
Color reduction is often needed for image segmentation, where images are partitioned into multiple regions or objects, usually by grouping adjacent pixels with similar colors or intensities. Vectorization (eg when converting raster images to SVG format) is one example of this process.
Historically image color reduction was essential for a couple of reasons: 1: because most displays had limited color resolutions, commonly 256 colors; 2. because early computers had very small hard drives as file storage was expensive, and compressed image file formats were yet to be invented. Reducing colors was the mainstay for smaller image files.
Note: CQ stands for Color Quantization, the process of reducing the number of distinct colors in an image.
uses Img32, Img32.CQ, Img32.Fmt.BMP; ... var colors: TArrayOfColor32; img: TImage32; essentialColors: TArrayOfColor32; begin img := TImage32.Create; img.LoadFromFile('beetle.bmp'); essentialColors := [clWhite32, clBlack32]; colors := CreatePalette(img, 16, essentialColors); ApplyPalette(img, colors, true); img.SaveToFile('beetle_16.bmp'); img.Free; end;
Copyright ©2019 Angus Johnson - Image32 ver. 3.2 - Documentation last updated on 15-September-2021