摘要 |
A method for generating a palette-based output image from a source image by variably dithering regions of the source image using an associated regional dithering mask. The palletized output image can be a GIF image or a PNG8 image. The dithering mask contains a plurality of dithering levels specifying the degree to which colors in corresponding regions of the source image can be dithered to paint the output image. The dithering mask stores dithering levels for the source image on a per pixel basis. The dithering mask is stored as an alpha channel of the source image. The palletized output file is generated from the source image on a per pixel basis. For each pixel, a target color is calculated by adding an accumulated error from neighboring pixels to the true color of a corresponding pixel in the source image. The output pixel is painted with the closest color to the target color that is available in the output file's color table. A color error is calculated by subtracting the output pixel's paint color from it's target color, and multiplying the difference by a dithering level obtained from a corresponding pixel in a dithering mask. The color error is diffused to neighboring pixels according to a dithering algorithm, such as the Floyd-Steinberg dithering algorithm.
|