%function compress2 created by: Dion Monstavicius % % This function takes and intensitymap and a blur map and encodes % the information as an ordered quadruple.... % It returns a matrix of quarduples and a computation of the entropy. function [orderedquadruplet, entropy] = compress2(intensitymap, blurmap) [A B] = find(intensitymap ~= 0); for i = 1:length(A), orderedquadruplet(i,:) = [A(i) B(i) intensitymap(A(i),B(i)) blurmap(A(i),B(i))]; end [A B] = size(orderedquadruplet); temp = reshape(orderedquadruplet, A*B,1); counts = hist(temp, round(max(temp))); counts = counts/sum(counts); H = 0; for i = 1:length(counts), if counts(i) ~= 0, H = H + counts(i)*log2(1/counts(i)); end end entropy = H;