From f618466c25d43f3bae9e40920273bf77de1e1149 Mon Sep 17 00:00:00 2001 From: leochanj105 Date: Mon, 19 Oct 2020 23:09:30 -0400 Subject: initial sd-vbs initial sd-vbs add sd-vbs sd-vbs --- .../src/matlabPyrTools/entropy2.m | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/entropy2.m (limited to 'SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/entropy2.m') diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/entropy2.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/entropy2.m new file mode 100755 index 0000000..68a2a9f --- /dev/null +++ b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/entropy2.m @@ -0,0 +1,31 @@ +% E = ENTROPY2(MTX,BINSIZE) +% +% Compute the first-order sample entropy of MTX. Samples of VEC are +% first discretized. Optional argument BINSIZE controls the +% discretization, and defaults to 256/(max(VEC)-min(VEC)). +% +% NOTE: This is a heavily biased estimate of entropy when you +% don't have much data. + +% Eero Simoncelli, 6/96. + +function res = entropy2(mtx,binsize) + +%% Ensure it's a vector, not a matrix. +vec = mtx(:); +[mn,mx] = range2(vec); + +if (exist('binsize') == 1) + nbins = max((mx-mn)/binsize, 1); +else + nbins = 256; +end + +[bincount,bins] = histo(vec,nbins); + +%% Collect non-zero bins: +H = bincount(find(bincount)); +H = H/sum(H); + +res = -sum(H .* log2(H)); + -- cgit v1.2.2