硬汉嵌入式论坛

 找回密码
 立即注册
查看: 5820|回复: 1
收起左侧

[LibJPEG] 【LibJPEG专题系列五】JPEG的良好“质量”设置

[复制链接]

740

主题

1326

回帖

3546

积分

管理员

春暖花开

Rank: 9Rank: 9Rank: 9

积分
3546
QQ
发表于 2015-4-13 11:28:33 | 显示全部楼层 |阅读模式
    Section - [5] What are good "quality" settings for JPEG?
Most JPEG compressors let you pick a file size vs. image quality tradeoff by selecting a quality setting.  There seems
to be widespread confusion about the meaning of these settings.  "Quality 95" does NOT mean "keep 95% of the
information", as some have claimed.  The quality scale is purely arbitrary; it's not a percentage of anything.


In fact, quality scales aren't even standardized across JPEG programs. The quality settings discussed in this article
apply to the free IJG JPEG software (see part 2, item 15), and to many programs based on it.  Some other JPEG
implementations use completely different quality scales. For example:  
    * Apple used to use a scale running from 0 to 4, not 0 to 100.  
    * Recent Apple software uses an 0-100 scale that has nothing to do with the IJG scale (their Q 50 is about the
same as Q 80 on the IJG scale).
     * Paint Shop Pro's scale is the exact opposite of the IJG scale, PSP setting N = IJG 100-N; thus lower numbers
are higher quality in PSP.  
    * Adobe Photoshop doesn't use a numeric scale at all, it just gives you "high"/"medium"/"low" choices.  (But I
hear this is changing in 4.0.)
Fortunately, this confusion doesn't prevent different implementations from exchanging JPEG files.  But you do need
to keep in mind that quality scales vary considerably from one JPEG-creating program to another, and that just
saying "I saved this at Q 75" doesn't mean a thing if you don't say which program you used.


In most cases the user's goal is to pick the lowest quality setting, or smallest file size, that decompresses into an image
indistinguishable from the original.  This setting will vary from one image to another and from one observer to another,
but here are some rules of thumb.


For good-quality, full-color source images, the default IJG quality setting (Q 75) is very often the best choice.  This
setting is about the lowest you can go without expecting to see defects in a typical image.  Try Q 75 first; if you see
defects, then go up.


If the image was less than perfect quality to begin with, you might be able to drop down to Q 50 without objectionable
degradation.  On the other hand, you might need to go to a *higher* quality setting to avoid further loss. This is often
necessary if the image contains dithering or moire patterns (see "[9] What are some rules of thumb for converting GIF
images to JPEG?").


Except for experimental purposes, never go above about Q 95; using Q 100 will produce a file two or three times as
large as Q 95, but of hardly any better quality.  Q 100 is a mathematical limit rather than a useful setting. If you see
a file made with Q 100, it's a pretty sure sign that the maker didn't know what he/she was doing.


If you want a very small file (say for preview or indexing purposes) and are prepared to tolerate large defects, a Q
setting in the range of 5 to 10 is about right.  Q 2 or so may be amusing as "op art".  (It's worth mentioning that the
current IJG software is not optimized for such low quality factors. Future versions may achieve better image quality
for the same file size at low quality settings.)


If your image contains sharp colored edges, you may notice slight fuzziness or jagginess around such edges no matter
how high you make the quality setting.  This can be suppressed, at a price in file size, by turning off chroma
downsampling in the compressor.  The IJG encoder regards downsampling as a separate option which you can turn
on or off independently of the Q setting.  With the "cjpeg" program, the command line switch "-sample 1x1" turns
off downsampling; other programs based on the IJG library may have checkboxes or other controls for downsampling.
  Other JPEG implementations may or may not provide user control of downsampling.  Adobe Photoshop, for example,
automatically switches off downsampling at its higher quality settings.  On most photographic images, we recommend
leaving downsampling on, because it saves a significant amount of space at little or no visual penalty.


For images being used on the World Wide Web, it's often a good idea to give up a small amount of image quality in order
to reduce download time. Quality settings around 50 are often perfectly acceptable on the Web. In fact, a user viewing
such an image on a browser with a 256-color display is unlikely to be able to see any difference from a higher quality
setting, because the browser's color quantization artifacts will swamp any imperfections in the JPEG image itself.  It's
also worth knowing that current progressive-JPEG-making programs use default progression sequences that are
tuned for quality settings around 50-75: much below 50, the early scans will look really bad, while much above 75,
the later scans won't contribute anything noticeable to the picture.
努力打造安富莱高质量微信公众号:点击扫描图片关注
回复

使用道具 举报

740

主题

1326

回帖

3546

积分

管理员

春暖花开

Rank: 9Rank: 9Rank: 9

积分
3546
QQ
 楼主| 发表于 2015-4-13 11:36:34 | 显示全部楼层
                  Section 5JPEG的良好“质量”设置?


    大多数JPEG压缩让你通过一个质量设置权衡文件大小与图像质量。人们对于这些设置的含义普遍
比较困惑。“Quality 95”不是指“保留95%的信息”,就像一些已经申明的。质量量表纯粹是随意的,它
并不是任何一个百分比。


    事实上,质量量表在整个JPEG程序中是不规范的。本文中讨论的质量设置适用于自由IJG JPEG软件
(见第2部分,第15项),以及基于它的许多程序。其他一些JPEG的实现是使用完全不同的质量量表。
例如:
    *  苹果过去常常使用一个从04运行的量表,而非从0100
    *  最近的苹果软件使用一个0100的量表,而这个量表和IJG量表没有关系。(其中Q50IJG量表
中的Q80差不多相同)
    *  Paint Shop Pro量表和IJG量表正好相反,PSP的设置N=IJG100-N。所以越小的数字代表的是
PSP中越高的质量。
    *  Adobe Photoshop不使用数字量表,它只提供“高”“中”“低”级的选择。(不过,我听说在4.0
版本中,这种情况正在改变。)
    幸运的是,这种混乱并不会组织不同的实现方式来交换JPEG文件。但是,需要记住的是,质量量表在
不同JPEG创建程序之间的差异很大,也就意味着,如果不说清楚你使用的程序是哪个,那么“我保存的
Q75”这句话则毫无意义。


    在大多数情况下,用户的目标是选择最低质量设置,或最小文件大小,将之分解成原来没有区别
图像。这种设置会在图像之间与服务器之间发生变化,但是仍有一些经验法则。


    为了获得良好的品质,全彩色源图像,默认IJG质量设置(Q75)往往是最好的选择。在典型的图像中,
这种设置将达到你不希望看到缺陷的最低设置。首先尝试Q75,如果你看到缺陷,就调高设置。


    如果开始时图像不是特别完美的质量,你或许可以将设置下调到Q50。另一方面,你可能需要一个稍高
的质量设置来避免进一步的损失。如果图像包含抖动色或莫尔条纹,这往往是必要的。(见[9] GIF图像
转换为JPEG的经验法则)


    除了实验目的,永远不要尝试高于Q95。使用Q100会产生一个相当于二或三倍Q95大小的文件,但是
几乎没有更好的质量。Q100是一个数学极值,而不是一个有用的设置。如果一个文件使用的是Q100,那
么很明显,制图者当时肯定是醉了,不知道自己在做什么。


    如果你想要一个非常小的文件(用于预览或索引的目的)并且准备接受很大的缺陷,在510之间的Q
设置会是一个正确的选择。Q 2左右可能和“欧普艺术”一样有趣。(值得一提的是,目前的IJG软件没有
对这种低质量的因素进行优化。对于相同大小的文件,未来的版本在低质量设置中可能会得到更好的图像
质量。)


    若图像包含明显的有色边缘,无论质量设置有多高,你需要注意这些边缘周围的轻微模糊或是锯齿。
通过关闭压缩机里的色度向下采样,之前的情况可以被抑制,付出代价的则是文件的大小。IJG编码器将
向下采样作为一个你可以自主开启或关闭Q设置的单独选项。随着“cjpeg”程序,命令行开关“-sample
1x1”关闭向下采样;而基于IJG库的其它程序可能有复选框或其他控件。其他JPEG的实现或可能或不能
提供向下采样的用户控制。举例来说,Adobe Photoshop会在其较高的质量设置时,自动关闭向下采样。
对于大多数的摄影图像,我们建议保留向下采样,因为它会显著地节省大量的空间,同时很少甚至没有
可见的缺陷。


    由于图像被用于万维网,放弃少量图像质量来减少下载时间是个很好的想法。50左右的质量设置在
网络上完全可以接受。事实上,在一个256色显示的浏览器上查看图像的用户,根本不可能看出它与更
高质量设置图像之间的不同。因为浏览器的彩色量化将会掩盖JPEG图像本身的所有缺陷。值得了解的
是,目前的逐行JPEG决策程序使用默认的级数序列(已经被调整为50-75之间的质量设置)——远低于
50,早期的扫描将会看起来很糟糕,而远高于75,后面的扫描将对图像没有任何显著的贡献。
努力打造安富莱高质量微信公众号:点击扫描图片关注
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|Archiver|手机版|硬汉嵌入式论坛

GMT+8, 2024-5-12 03:46 , Processed in 0.192812 second(s), 25 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表