本文主要是介绍图像的联合概率分布,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
如何计算两幅图像的联合概率分布
https://www.medphysics.wisc.educourses/mp573/2010/mutualinformation_revised.pdf
中给出的定义是:
The spatial information obviously required for a registration method is provided by the definition of a joint probability distribution that depends simultaneously on image A and B. The conventional expression for it is p A , B ( a , b ) p_{A,B} (a, b) pA,B(a,b). It is calculated as the number of times out of the total number of pixels N that a pixel in A contains the value a and the same pixel that is, the pixel in the same image position, in B contains the value b; this number of pixels is then divided by the total number of pixels to give the joint probability of a,b.
个人的理解是:
- 图像配准需要的空间信息取决于图像A和B的联合概率分布,它的常规表达式是 p A , B ( a , b ) p_{A,B} (a, b) pA,B(a,b) 。
- 统计图像A中像素为a的位置,计算B中处于和a相同位置的像素b的个数n;
- 将n除以像素总数N,得到a,b的联合概率。
假如图像分别为
A = ( 1 1 2 2 7 1 ) A=\left(\begin{array}{lll}1 & 1 & 2 \\2 & 7 & 1\end{array}\right) A=(121721)
B = ( 1 2 2 2 1 2 ) B=\left(\begin{array}{lll}1 & 2 & 2 \\2 & 1 & 2\end{array}\right) B=(122122)
则图像的联合概率分布为
p A , B ( 1 , 1 ) = 1 6 p_{A,B}(1,1)=\frac 16 pA,B(1,1)=61
p A , B ( 1 , 2 ) = 2 6 p_{A,B}(1,2)=\frac 26 pA,B(1,2)=62
p A , B ( 1 , 7 ) = 0 6 p_{A,B}(1,7)=\frac 06 pA,B(1,7)=60
p A , B ( 2 , 1 ) = 0 6 p_{A,B}(2,1)=\frac 06 pA,B(2,1)=60
p A , B ( 2 , 2 ) = 2 6 p_{A,B}(2,2)=\frac 26 pA,B(2,2)=62
p A , B ( 2 , 7 ) = 0 6 p_{A,B}(2,7)=\frac 06 pA,B(2,7)=60
p A , B ( 7 , 1 ) = 1 6 p_{A,B}(7,1)=\frac 16 pA,B(7,1)=61
p A , B ( 7 , 2 ) = 0 6 p_{A,B}(7,2)=\frac 06 pA,B(7,2)=60
p A , B ( 7 , 7 ) = 0 6 p_{A,B}(7,7)=\frac 06 pA,B(7,7)=60
- 虽然有 3 2 3^2 32个可能的有序像素值对需要考虑,但总匹配数将只有6个。至于我们是否应该称之为“两幅图像的联合概率分布”——这只是作者们想要使用的术语。有很多种方法来获取图像的属性并定义联合分布。
https://www.physicsforums.com/threads/joint-probability-distribution-of-two-images.589741/
参考两幅图像联合熵的概念,对上述理解用Matlab进行验证
%A=rgb2gray(imread('img1.png'))
%B=rgb2gray(imread('img2.png'))% 给出A,B矩阵
img1=[1,1,2;2,7,1];
img2=[1,2,2;2,1,2];
A=double(img1)+1;
B=double(img2)+1;
[M,N]=size(A);
Large=max(max(max(A),max(B)))+1;
temp=zeros(Large,Large);
for m=1:Mfor n=1:Ni=A(m,n)j=B(m,n);temp(i,j)=temp(i,j)+1;end
end
temp=temp./(M*N);
验证temp为
[ 1 / 6 2 / 6 ⋯ 0 0 2 / 6 ⋯ 0 ⋮ ⋮ ⋱ ⋮ 1 / 6 0 ⋯ 0 ] \begin{bmatrix} {1/6}&{2/6}&{\cdots}&{0}\\ {0}&{2/6}&{\cdots}&{0}\\ {\vdots}&{\vdots}&{\ddots}&{\vdots}\\ {1/6}&{0}&{\cdots}&{0}\\ \end{bmatrix} ⎣⎢⎢⎢⎡1/60⋮1/62/62/6⋮0⋯⋯⋱⋯00⋮0⎦⎥⎥⎥⎤
与上述计算一致。
这篇关于图像的联合概率分布的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!