1 内容介绍
图像压缩是图像传输和存储中最重要的步骤之一。 大多数最先进的图像压缩技术都是基于空间的。 在此代码中,基于多级图像阈值实现了基于直方图的图像压缩技术。 图像的灰度被划分为一组清晰的概率分区。 香农熵用于衡量清晰分组的随机性。 熵函数使用一种流行的称为差分进化的元启发式算法来最大化,以减少优化目标值的计算时间和标准偏差。
2 仿真代码
function entropy=shannonEntropy(x,h)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% INPUTS : x is the threshold vector
% h is the histrogram of the image
% OUTPUT: entropy is the Entropy of the image after probabilistic
% partition by the threshold vector 'h'
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Written by : Sujoy Paul, Jadavpur University, Kolkata %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
entropy=0;
x=[1 (x+1) 256];
s=size(x);
for i=1:s(2)-1
temp = h(x(i):x(i+1));
tsum= sum(temp);
ent=0;
if tsum~=0
for j=x(i):x(i+1)
if h(j)~=0
a=h(j)/tsum;
ent = ent + a*log(a);
end
end
end
entropy = entropy + ent;
end
entropy=-entropy;
3 运行结果
编辑
4 参考文献
[1] Paul S . A novel approach for image compression based on multi-level image thresholding using Shannon Entropy[J]. Differential Evolution.
博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。
部分理论引用网络文献,若有侵权联系博主删除。