Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Filter PNG编码器如何选择要使用的过滤器?_Filter_Png_Image Compression_Libpng_Encoder - Fatal编程技术网

Filter PNG编码器如何选择要使用的过滤器?

Filter PNG编码器如何选择要使用的过滤器?,filter,png,image-compression,libpng,encoder,Filter,Png,Image Compression,Libpng,Encoder,可以为图像的每一行单独选择。它首先提出一些一般性建议: 索引彩色和

可以为图像的每一行单独选择。它首先提出一些一般性建议:

索引彩色和<8位彩色图像不应使用过滤器 真彩色和灰度图像:五种滤镜中的任何一种都可能被证明是最有效的 如果您只能对整个图像使用一个过滤器,那么Paeth可能是最好的 ,这听起来像是在PNG发展的早期写的,并不是很具体:

以下简单的启发式算法在早期测试中表现良好:使用所有五个过滤器计算输出扫描线,并选择输出绝对值之和最小的过滤器。将输出字节视为此测试的签名差异。这种方法通常优于任何单一的固定滤波器选择。然而,随着PNG获得更多经验,可能会发现更好的启发式方法

编码器通常如何选择使用的过滤器?上述方法是典型的还是更现代的方法

编辑: @Mark Setchell指向,其中包含从第2416行开始的长注释:


阅读libpng中pngwutil.c的第2550行。我的c非常糟糕,我不知道那里发生了什么——关于求和值的事情?你能给我一个解释吗?我不觉得这是世界上最容易读懂的代码,但我的理解是,除非调用者明确指出了他想要使用的过滤器,否则所有过滤器都会被尝试,并选择输出长度最小的过滤器。如果发现错误,我很高兴被纠正:-在第2416行有一个扩展的评论-也许这解释了选择?更多信息。。。
/* The prediction method we use is to find which method provides the
 * smallest value when summing the absolute values of the distances
 * from zero, using anything >= 128 as negative numbers.  This is known
 * as the "minimum sum of absolute differences" heuristic.  Other
 * heuristics are the "weighted minimum sum of absolute differences"
 * (experimental and can in theory improve compression), and the "zlib
 * predictive" method (not implemented yet), which does test compressions
 * of lines using different filter methods, and then chooses the
 * (series of) filter(s) that give minimum compressed data size (VERY
 * computationally expensive).
 *
 * GRR 980525:  consider also
 *
 *   (1) minimum sum of absolute differences from running average (i.e.,
 *       keep running sum of non-absolute differences & count of bytes)
 *       [track dispersion, too?  restart average if dispersion too large?]
 *
 *  (1b) minimum sum of absolute differences from sliding average, probably
 *       with window size <= deflate window (usually 32K)
 *
 *   (2) minimum sum of squared differences from zero or running average
 *       (i.e., ~ root-mean-square approach)
 */