求图像信息熵,基于matlab

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

图像的信息熵的程序

>> A=imread('C:\Users\dmin\Desktop\133194489.jpg');

>> [M,N]=size(A);

temp=zeros(1,256);

for m=1:M;

for n=1:N;

if A(m,n)==0;

i=1;

else

i=A(m,n);

end

temp(i)=temp(i)+1;

end

end

temp=temp/(M*N);

result=0;

for i=1:length(temp)

if temp(i)==0;

result=result;

else

result=result-temp(i)*log2(temp(i));

end

end

result

运行MATLAB结果如下

result =

6.8645

黑白图片

>> A=imread('C:\Users\dmin\Desktop\t011168b065a19ba23d.jpg');

>> [M,N]=size(A);

temp=zeros(1,256);

for m=1:M;

for n=1:N;

if A(m,n)==0;

i=1;

else

i=A(m,n);

end

temp(i)=temp(i)+1;

end

end

temp=temp/(M*N);

result=0;

for i=1:length(temp)

if temp(i)==0;

result=result;

else

result=result-temp(i)*log2(temp(i));

end

end

result

运行MATLAB结果如下

result =

7.0214

相关文档
最新文档