www.pudn.com > duge.rar > comb_inf.m, change:2014-11-09,size:1022b


function [ value ] = comb_inf( I,J,F ) 
%COMB_INF Summary of this function goes here 
%   Detailed explanation goes here 
 if ndims(I)==3 
     I=rgb2gray(I); 
 end 
 if ndims(J)==3 
     J=rgb2gray(J); 
 end 
 if ndims(F)==3 
     F=rgb2gray(F); 
 end 
 Pi=imhist(I); 
 Pj=imhist(J); 
 Pf=imhist(F); 
 [rows,cols] = size(I); 
 h_IF = zeros(256,256); 
 h_JF = zeros(256,256); 
 for k = 1:rows 
     for l = 1:cols 
         h_IF(I(k,l)+1,F(k,l)+1) = h_IF(I(k,l)+1,F(k,l)+1)+1; % 更新联合直方图 
         h_JF(J(k,l)+1,F(k,l)+1) = h_JF(J(k,l)+1,F(k,l)+1)+1;  
     end 
 end 
 Pif=h_IF/max(max(h_IF)); 
 Pjf=h_JF/max(max(h_JF)); 
 value1=0; 
 value2=0; 
 for i=1:256 
     for j=1:256 
         if (Pif(i,j)~=0)&&(Pi(j)~=0)&&(Pf(i)~=0)            
             value1=value1+Pif(i,j)*log2(Pif(i,j)/(Pf(i)*Pi(j))); 
         end 
         if (Pjf(i,j)~=0)&&(Pj(j)~=0)&&(Pf(i)~=0)            
             value2=value2+Pjf(i,j)*log2(Pjf(i,j)/(Pf(i)*Pj(j))); 
         end 
     end 
 end 
 value=-(value1+value2); 
 
end