图像处理 20:1 压缩,逐步推导 jpeg 格式压缩过程,包括数学原理解析

栏目: IT技术 · 发布时间: 4年前

内容简介:Using DCT is for extracting the approximation of the photo and omit detail, because human eyes don't perceive changes too much in detail, so .Jpeg uses this idea to filter out the details of the photo for reducing the photo size.DCT is similar to Fourier t

JPEG-DCT-Compression

catalog
│── 1. Preset
│   │──  1.1 Read image, set bits occupied by "Run-Length", use RGB-to-YCbCr or not and block size.
│   └──  1.2 Transfer RGB image to YCbCr Image if you want
│── 2. Transform the image into blocks  
│── 3. DCT (Discrete Cosine Transform)
│   │──  3.1 operate DCT on all the blocks respectively, check the difference between step-2 and step-3  
│   │──  3.2 Why DCT (0,0) or (0) is called DC? and why it is the most light point?
│   └──  3.3 How it looks like transforming the DCT blocks back to image?
│── 4. Quantized DCT(save approximations, omit details)  
│   │── 4.1 Use default quantization table(you can find it in google) to quantize all dct blocks  
│   │── 4.2 Transform the quantized dct blocks back to image, check the difference between step-3.1 and step-4.2  
│   │── 4.3 Try a random bad quantization table to check the difference of result image.  
│   └── 4.4 Decompression(image reconstruction) of 3 kinds of DCT(check difference)  
│── 5. Example of saving one quantized DCT block as small size as it can be  
│   │── 5.1 Zig-Zag process  
│   │── 5.2 Huffman Coding  
│   │── 5.3 Run-Length encoding(with VLI Variable-length-integer encoding)  
│   └── 5.4 Save the result of Run-Length to bytes  
│── 6. Saving as jpeg, do step-5 for all blocks of the image  
│── 7. Decoding  
│   │── 7.1 Run-Length decoding  
│   └── 7.2 Zig-Zag decoding  
│       └── 7.2.1 Another Zig-Zag Decoding  
└── 8. Loading the jpeg, decompression of compressed(encoded) image

Basic idea of DCT

Using DCT is for extracting the approximation of the photo and omit detail, because human eyes don't perceive changes too much in detail, so .Jpeg uses this idea to filter out the details of the photo for reducing the photo size.

DCT is similar to Fourier transform, below is doing Fourier transform on the whole picture and then generate its high-pass and low-pass pictures. 图像处理 20:1 压缩,逐步推导 jpeg 格式压缩过程,包括数学原理解析

Run all Code cells from beginning to end

These are the parameters you could modify:

w=8 #modify it if you want, maximal 8 due to default quantization table is 8*8
h=w
runBits=1 #modify it if you want
bitBits=3  #modify it if you want
useYCbCr=True #modify it if you want
useHuffman=True #modify it if you want
quantizationRatio=1 #quantization table=default quantization table * quantizationRatio

For above default parameters, the result is below

I only focus on explanations, so didn't improve duration that much:

Image original size: 2.250 MB

Compression image size: 0.110 MB

Compression ratio: 20.41 : 1

Encoding: 12.198627233505249 seconds

Decoding: 2.6317562580108643 seconds

Original image: 图像处理 20:1 压缩,逐步推导 jpeg 格式压缩过程,包括数学原理解析 Compression image: 图像处理 20:1 压缩,逐步推导 jpeg 格式压缩过程,包括数学原理解析


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Python金融衍生品大数据分析:建模、模拟、校准与对冲

Python金融衍生品大数据分析:建模、模拟、校准与对冲

【德】Yves Hilpisch(伊夫·希尔皮斯科) / 蔡立耑 / 电子工业出版社 / 2017-8 / 99.00

Python 在衍生工具分析领域占据重要地位,使机构能够快速、有效地提供定价、交易及风险管理的结果。《Python金融衍生品大数据分析:建模、模拟、校准与对冲》精心介绍了有效定价期权的四个领域:基于巿场定价的过程、完善的巿场模型、数值方法及技术。书中的内容分为三个部分。第一部分着眼于影响股指期权价值的风险,以及股票和利率的相关实证发现。第二部分包括套利定价理论、离散及连续时间的风险中性定价,并介绍......一起来看看 《Python金融衍生品大数据分析:建模、模拟、校准与对冲》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码