硬汉嵌入式论坛

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

[LibJPEG] 【LibJPEG专题系列二】为什么使用JPEG

[复制链接]

740

主题

1326

回帖

3546

积分

管理员

春暖花开

Rank: 9Rank: 9Rank: 9

积分
3546
QQ
发表于 2015-4-5 14:33:35 | 显示全部楼层 |阅读模式
                                     JPEG 图像压缩 FAQ, part 1
                      Section - [2] Why use JPEG?

There are two good reasons: to make your image files smaller, and to store 24-bit-per-pixel color
data instead of 8-bit-per-pixel data.


Making image files smaller is a win for transmitting files across networks and for archiving libraries
of images.  Being able to compress a 2 Mbyte full-color file down to, say, 100 Kbytes makes a big
difference in disk space and transmission time!  And JPEG can easily provide 20:1 compression of
full-color data.  If you are comparing GIF and JPEG, the size ratio is usually more like 4:1 (see "[4]
How well does JPEG compress images?").


Now, it takes longer to decode and view a JPEG image than to view an image of a simpler format
such as GIF.  Thus using JPEG is essentially a time/space tradeoff: you give up some time in order
to store or transmit an image more cheaply.  But it's worth noting that when network transmission
is involved, the time savings from transferring a shorter file can be greater than the time needed
to decompress the file.


The second fundamental advantage of JPEG is that it stores full color information: 24 bits/pixel (16
million colors).  GIF, the other image format widely used on the net, can only store 8 bits/pixel (256
or fewer colors). GIF is reasonably well matched to inexpensive computer displays --- most
run-of-the-mill PCs can't display more than 256 distinct colors at once. But full-color hardware
is getting cheaper all the time, and JPEG photos look *much* better than GIFs on such hardware.  
Within a couple of years, GIF will probably seem as obsolete as black-and-white MacPaint
format does today.  Furthermore, JPEG is far more useful than GIF for exchanging images
among people with widely varying display hardware, because it avoids prejudging how many
colors to use (see "[8] What is color quantization?"). Hence JPEG is considerably more appropriate
than GIF for use as a Usenet and World Wide Web standard photo format.


A lot of people are scared off by the term "lossy compression".  But when it comes to representing
real-world scenes, *no* digital image format can retain all the information that impinges on your
eyeball.  By comparison with the real-world scene, JPEG loses far less information than GIF.
The real disadvantage of lossy compression is that if you repeatedly compress and decompress
an image, you lose a little more quality each time (see "[10] Does loss accumulate with repeated
compression/decompression?"). This is a serious objection for some applications but matters not
at all for many others.
努力打造安富莱高质量微信公众号:点击扫描图片关注
回复

使用道具 举报

740

主题

1326

回帖

3546

积分

管理员

春暖花开

Rank: 9Rank: 9Rank: 9

积分
3546
QQ
 楼主| 发表于 2015-4-5 14:36:34 | 显示全部楼层
JPEG 图像压缩 FAQ, part 1
                     Section 2—为什么使用JPEG?

有两个很好的理由:一是让你的图像文件更小,二是用于存储每像素24位的颜色数据来代替
每像素8位的数据。


在通过网络进行文件传输以及归档图像库方面,使图像文件更小就实现了两者的双赢。比如说,
能够压缩一个2 MB的全彩文件减少成一个100 KB的文件,这将在磁盘空间以及传输时间上有了
很大的不同。而且JPEG能够很容易的提供一个20:1的全彩数据的压缩。如果你正在对比GIF
JPEG,他们的大小比率更像是41(见“[4]JPEG压缩图像的效果?”)


现在,相对于一个简单格式的(比如GIF图像,它需要更长的时间来解码并查看一个JPEG图像。
因此,使用JPEG实际上是时间/空间上的权衡:你放弃一些时间,来更轻易地存储或传输图像。
但值得一提的是,当涉及网络传输时,传输一个更小的文件所省下来的时间将会比解码文件所需
要的时间更大。


JPEG的第二个基本优点是,它存储的是全彩信息——每像素24位(即1600万种颜色)。网络上
广泛使用的另一种图像格式GIF,则只能存储每像素8位(256种或更少颜色)的信息。GIF很合
理的匹配于一些便宜的电脑显示器——大部分普通的计算机无法同时显示超过256种不同的颜色。
但是,全彩的硬盘一直都越来越便宜,而且在这样的硬盘上,JPEG图片看起来比GIF图片好得多。
短短几年内,GIF将有可能被认为是过时的,就好比现在MacPaint黑白格式所做的。此外,JPEG
GIF更有用,因为人们不用预先考虑需要使用多少种的颜色,就可以实现在广泛的不同种类的
显示硬盘中进行图像交换(见[8]颜色量化)。因此,JPEG是比GIF更适合用作新闻网以及万维
网的标准图像格式。

很多人被专业术语“有损压缩”吓跑了。但是当触及到代表“真实世界”的场景,没有一种数字
图像格式可以保留进入你眼球的所有信息。通过和“真实世界”的场景作对比,JPEG损耗的信
息比GIF少得多。有损压缩的真正缺点在于,如果你反复压缩与解压缩图像,每一次都会损耗图
像的质量(见[10] 重复压缩/解压缩的累计损失?)。对于某些应用程序来说,这是一个很严重的
意见,当然这并不影响其他的应用。
努力打造安富莱高质量微信公众号:点击扫描图片关注
回复

使用道具 举报

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

本版积分规则

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

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

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

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