the attached utility is a work I've submitted to the university
It shows what a jpeg compression is all about.
the function implements the DCT transform, using a matrix operator.
note that matlab has a function for the DCT and iDCT transforms
that might be more efficient.
some details of the algorithm:
a basic jpeg compression (graylevel image):
1) take an image (2D matrix) and devide it to 8x8 matrices
2) for each matrix (8x8) use the DCT conversion (from the signal
processing toolbox). you will get an (8x8) matrix as an answer
3) build an 8x8 matrix, which is the sum off all the matrices, such
that sum_matrix = A + B + C + ...
4) sort elements of the 8x8 matrix from the highest to the smallest
and get the indices list.
5) sum the last matrix with part of the elements which have the
higher coefficients, until you have a sufficient ratio (lets say
80%). for example :
idx = sort( sum_matrix (:) );
part_of_energy = sum_matrix(idx(1:20));
all_energy = sum_matrix(:);
ratio = part_of_energy/all_energy;
6) save the partial list of indices, number of matrices (rows,lines)
and from each matrix from step (2) save ONLY these coefficients
(remember the order you save them)
now this is the compressed data.
to reconstract
1) build matrices of step (2) by the zero command: A = zero(8,8); B
= zero(8,8); ...
(better to use a for loop...)
2) in each matrix, store the coefficients in the right places, such
that the new A matrix is equal to the A matrix from step (2) of the
encoding, except for the zeros where you don't know the coefficients.
3) for each matrix do the inverse transform (IDCT)
4) compose these inverse-transformed matrices back into a big matrix.
this is the reconstracted image
usually, you will have most of the energy inside the upper-left
coefficient (1,1) which corresponds to the DC (or average value) of
the whole picture.
enjoy,
Ohad Gal.
JPEG@matlab.rar_JPEG图像压缩_jpeg matlab
版权申诉
5星 · 超过95%的资源 176 浏览量
2022-09-24
14:47:53
上传
评论
收藏 84KB RAR 举报
林当时
- 粉丝: 97
- 资源: 1万+
最新资源
- 基于MFC的校园导航程序(使用最短路径dijkstra算法).rar
- Android Studio android APP 视频作为视图背景需要源代码或想了解其实现原理的可以私心我
- com.ZeroneGames.GreenProject.apk
- Python自动化开发入门教程
- 4399GameSem_116_13955_207551_6.apk
- python 3.9.19源码编译包
- php-8.2.18-Win32-vs16-x64.rar
- 字节跳动青训营-抖音项目
- SQL资料手册,语句教程,高级查询语句语法
- 上位机和串口建立 Modbus 协议进行数据传输,并使用 Mysql 数据库存储,能够实现实时温湿度显示和动态变化曲线,历史数据
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈