MagickQuantize图像使用
我正在使用 ImageMagick 库处理一些图像。作为处理的一部分,如果这不影响图像质量(太多),我希望最大限度地减少颜色数量。
为此,我尝试使用 MagickQuantizeImage 函数。有人可以解释一下我应该选择谁的参数吗?
树深度:
通常,该整数值为零或一。 0 或 1 告诉 Quantize 选择 Log4(number_colors) 的最佳树深度。% 此深度的树通常允许以最少的内存量和最快的计算速度最好地表示参考图像。在某些情况下,例如颜色色散较低(几种颜色)的图像,需要 Log4(number_colors) 以外的值。要完全扩展颜色树,请使用值 8。
抖动:
非零值将原始图像与相应的减色算法之间的差异沿着希尔伯特曲线分布到相邻像素。
测量错误:
非零值测量原始图像和量化图像之间的差异。这个差异就是总量化误差。通过对图像中的所有像素求和每个参考像素值与其量化值之间在 RGB 空间中的距离的平方来计算误差。
ps:我做了一些测试,但有时图像质量受到严重影响,我不想通过反复试验找到结果。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是对算法 http://www.imagemagick.org/www/quantize 的非常好的描述
。 html
它们引用的是命令行版本,但概念是相同的。
参数
measure_error
旨在指示您得到的答案有多好。设置为非零,然后在量化后查看 Image 对象的mean_error_per_pixel 字段,看看您获得的量化效果如何。如果不够好,请增加颜色数量。
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.