Introduction to JPEG Compression

转自: http://www.tutorialspoint.com/dip/introduction_to_jpeg_compression.htm


Introduction to JPEG Compression


Advertisements


In our last tutorial of image compression, we discuss some of the techniques used for compression

We are going to discuss JPEG compression which is lossy compression, as some data is loss in the end.

Let’s discuss first what image compression is.

Image compression

Image compression is the method of data compression on digital images.

The main objective in the image compression is:

  • Store data in an efficient form
  • Transmit data in an efficient form

Image compression can be lossy or lossless.

JPEG compression

JPEG stands for Joint photographic experts group. It is the first interanational standard in image compression. It is widely used today. It could be lossy as well as lossless . But the technique we are going to discuss here today is lossy compression technique.

How jpeg compression works

First step is to divide an image into blocks with each having dimensions of 8 x8.

JPEG Compression

Let’s for the record, say that this 8x8 image contains the following values.

JPEG Compression

The range of the pixels intensities now are from 0 to 255. We will change the range from -128 to 127.

Subtracting 128 from each pixel value yields pixel value from -128 to 127. After subtracting 128 from each of the pixel value, we got the following results.

JPEG Compression

Now we will compute using this formula.

JPEG Compression

The result comes from this is stored in let’s say A(j,k) matrix.

There is a standard matrix that is used for computing JPEG compression, which is given by a matrix called as Luminance matrix.

This matrix is given below

JPEG Compression

Applying the following formula

JPEG Compression

We got this result after applying.

JPEG Compression

Now we will perform the real trick which is done in JPEG compression which is ZIG-ZAG movement. The zig zag sequence for the above matrix is shown below. You have to perform zig zag until you find all zeroes ahead. Hence our image is now compressed.

JPEG Compression

Summarizing JPEG compression

The first step is to convert an image to Y’CbCr and just pick the Y’ channel and break into 8 x 8 blocks. Then starting from the first block, map the range from -128 to 127. After that you have to find the discrete Fourier transform of the matrix. The result of this should be quantized. The last step is to apply encoding in the zig zag manner and do it till you find all zero.

Save this one dimensional array and you are done.

Note. You have to repeat this procedure for all the block of 8 x 8.

用matlab 图像处理教材提供的代码验证:

    52    55    61    66    70    61    64    73
    63    59    55    90   109    85    69    72
    62    59    68   113   144   104    66    73
    63    58    71   122   154   106    70    69
    67    61    68   104   126    88    68    70
    79    65    60    70    77    68    58    75
    85    71    64    59    55    61    65    83
    87    79    69    68    65    76    78    94

运行程序的结果为:

-26    -3    -6     2     2    -1     0     0
     0    -2    -4     1     1     0     0     0
    -3     1     5    -1    -1     0     0     0
    -3     1     2    -1     0     0     0     0
     1     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0
     0     0     0     0     0     0     0     0


其它有用的参考文献:

http://cs.stanford.edu/people/eroberts/courses/soco/projects/data-compression/lossy/jpeg/dct.htm

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值