1 简介
介绍了JPEG图像压缩算法,并在MATLAB数学分析工具环境下从实验角度出发,较为直观地探讨了DCT在JPEG图像压缩中的应用.仿真实验表明,用MATLAB来实现离散余弦变换的图像压缩,具有方法简单,速度快,误差小的优点,大大提高了图像压缩的效率和精度.
2 部分代码
function rmse = compare(f1, f2, scale)
%COMPARE Computes and displays the error between two matrices.
% RMSE = COMPARE(F1, F2, SCALE) returns the root-mean-square error
% between inputs F1 and F2, displays a histogram of the difference,
% and displays a scaled difference image. When SCALE is omitted, a
% scale factor of 1 is used.
% Check input arguments and set defaults.
error(nargchk(2, 3, nargin));
if nargin < 3
scale = 1;
end
% Compute the root-mean-square error.
e = double(f1) - double(f2);
[m, n] = size(e);
rmse = sqrt(sum(e(:) .^ 2) / (m * n));
% Output error image & histogram if an error (i.e., rmse ~= 0).
% if rmse
% Form error histogram.
%emax = max(abs(e(:)));
%[h, x] = hist(e(:), emax);
%if length(h) >= 1
%figure; bar(x, h, 'k');
% Scale the error image symmetrically and display
% emax = emax / scale;
%e = mat2gray(e, [-emax, emax]);
%figure; imshow(e);
% end
%end
3 仿真结果
4 参考文献
[1]李秀敏, 万里青, 周拥军. 基于MATLAB的DCT变换在JPEG图像压缩中的应用[J]. 电光与控制, 2005, 12(2):4.
博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。
部分理论引用网络文献,若有侵权联系博主删除。