图像熵的意义以及计算

来源:互联网 发布:淘宝有没有投诉电话 编辑:程序博客网 时间:2024/06/01 09:12

 转自: http://www.zhizhihu.com/html/y2010/1367.html

         熵(entropy)指的是体系的混乱的程度,它在控制论、概率论、数论、天体物理、生命科学等领域都有重要应用,在不同的学科中也有引申出的更为具体的 定义,是各领域十分重要的参量。熵由鲁道夫·克劳修斯(Rudolf Clausius)提出,并应用在热力学中。后来在,克劳德·艾尔伍德·香农(Claude Elwood Shannon)第一次将熵的概念引入到信息论中来。

图像熵表示为图像灰度级集合的比特平均数,单位比特/像素,也描述了图像信源的平均信息量。

: H(p)=-∑i,jp(i.j)lnp(i,j), 其中p(i,j)=x(i,j)∑i,jx(i,j),x(i,j)为图像的像元

%%%%%%%%%%%%%%%%Matlab源码%%%%%%%%%%%%%%

帮助
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
%计算一副图像的熵
  
%随机生成图像
A=floor(rand(8,8).*255);
  
[M,N]=size(A);
temp=zeros(1,256);
  
%对图像的灰度值在[0,255]上做统计
form=1:M;
for n=1:N;
  
ifA(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)
iftemp(i)==0;
result=result;
else
result=result-temp(i)*log2(temp(i));
end
end
result
  
%计算联合熵
  
%随机生成图像
A=floor(rand(8,8).*255);
B=floor(rand(8,8).*255);
  
[M,N]=size(A);
temp=zeros(256,256);
  
%对图像的灰度值成对地做统计
form=1:M;
forn=1:N;
  
if A(m,n)==0;
i=1;
else
i=A(m,n);
end
  
ifB(m,n)==0;
j=1;
else
j=B(m,n);
end
  
temp(i,j)=temp(i,j)+1;
end
end
temp=temp./(M*N);
  
%由熵的定义做计算
result=0;
  
for i=1:size(temp,1)
forj=1:size(temp,2)
iftemp(i,j)==0;
result=result;
else
result=result-temp(i,j)*log2(temp(i,j));
end
end
end
result
原创粉丝点击