Взаимная информация, Kullback Leibler Расхождение между двумя цветными изображениями - PullRequest
0 голосов
/ 30 марта 2019

Я работаю над проектом по классификации изображений с использованием взаимной информации. Это требует от меня использования вероятностного распределения цветного изображения, либо я хочу вычислить взаимную информацию, либо расхождение Кулбека Лейблера в Matlab. Кто-нибудь может мне помочь в этом? Я рассчитал энтропию цветного изображения как:

I = imread('s1.png');
% rgb_columns = reshape(rgb, [], 3);

% %Change RGB matrices to a single matrix of color indices.
% %Removes the third dimension from the pixel intensity matrix.
Color_ind=double(I(:,:,1)).*256^2+double(I(:,:,2).*256)+double(I(:,:,3));      
disp(size(Color_ind));     

% Finding unique elements in the matrix and find their length
unique_ind=unique(Color_ind);
unique_len=length(unique_ind);

%Pre-allocate space for the vector that will hold the number of entries
%for each unique color
color_count_prob=zeros(unique_len,1);

%Count the number of each occurrence of each unique color index in the 
%original matrix.
for i = 1:unique_len
  color_count_prob(i)=(length(find(unique_ind(i)==Color_ind)))/(2073600);
end
en_sum=0;
for i = 1:unique_len
  en_sum = en_sum + log2(color_count_prob(i));
end
en = -en_sum;
...