开发者

MagickQuantizeImage usage

I am processing some images using ImageMagick library. As part of 开发者_开发问答the processing I want to minimize the number of colors if this doesn't affect image quality (too much).

For this I have tried to use MagickQuantizeImage function. Can someone explain me whow should I choose the parameters ?

treedepth:

Normally, this integer value is zero or one. A zero or one tells Quantize to choose a optimal tree depth of Log4(number_colors).% A tree of this depth generally allows the best representation of the reference image with the least amount of memory and the fastest computational speed. In some cases, such as an image with low color dispersion (a few number of colors), a value other than Log4(number_colors) is required. To expand the color tree completely, use a value of 8.

dither:

A value other than zero distributes the difference between an original image and the corresponding color reduced algorithm to neighboring pixels along a Hilbert curve.

measure_error:

A value other than zero 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.

ps: I have made some tests but sometimes the quality of images in severely affected, and I don't want find a result by trial and error.


This is a really good description of the algorithm

http://www.imagemagick.org/www/quantize.html

They are referencing the command-line version, but the concepts are the same.

The parameter measure_error is meant to give you an indication of how good an answer you got. Set to non-zero, then look at the Image object's mean_error_per_pixel field after you quantize to see how good a quantization you got.

If it's not good enough, increase the number of colors.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜