function [Hxy] = entropy(I, d,phi) % % Written by: % -- % John L. Weatherwax 2005-08-04 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % % Epage % %----- if( nargin>1 ) % compute the entropy for just one displacement and angular direction P = co_occurrence(I, d,phi); indsP = find( P(:)>0 ); mv = min(P(indsP)); % fix any zero elements so we can take the log2 of them indsN = find( P(:)<=0 ); P(indsN) = 1.e-6 * mv; LP = log2(P); PnLP = -P .* LP; Hxy = sum(PnLP(:)); else % compute the entropy for all angles and average d = 1; % assume d=1 all_phis = [ 0, 45, 90, 135 ]; all_ents = zeros(1,length(all_phis)); for ii=1:length(all_phis) c = entropy(I, d,all_phis(ii)); % recursively call the three argument case all_ents(ii) = c; end Hxy = mean(all_ents); end