summaryrefslogtreecommitdiffstats
path: root/SD-VBS/benchmarks/texture_synthesis/src/matlab/histo.m
diff options
context:
space:
mode:
authorleochanj105 <leochanj@live.unc.edu>2020-10-19 23:09:30 -0400
committerleochanj105 <leochanj@live.unc.edu>2020-10-20 02:40:39 -0400
commitf618466c25d43f3bae9e40920273bf77de1e1149 (patch)
tree460e739e2165b8a9c37a9c7ab1b60f5874903543 /SD-VBS/benchmarks/texture_synthesis/src/matlab/histo.m
parent47ced4e96bbb782b9e780e8f2cfc637b2c21ff44 (diff)
initial sd-vbs
initial sd-vbs add sd-vbs sd-vbs
Diffstat (limited to 'SD-VBS/benchmarks/texture_synthesis/src/matlab/histo.m')
-rwxr-xr-xSD-VBS/benchmarks/texture_synthesis/src/matlab/histo.m58
1 files changed, 58 insertions, 0 deletions
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/histo.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/histo.m
new file mode 100755
index 0000000..8da36e5
--- /dev/null
+++ b/SD-VBS/benchmarks/texture_synthesis/src/matlab/histo.m
@@ -0,0 +1,58 @@
1% [N,X] = histo(MTX, nbinsOrBinsize, binCenter);
2%
3% Compute a histogram of (all) elements of MTX. N contains the histogram
4% counts, X is a vector containg the centers of the histogram bins.
5%
6% nbinsOrBinsize (optional, default = 101) specifies either
7% the number of histogram bins, or the negative of the binsize.
8%
9% binCenter (optional, default = mean2(MTX)) specifies a center position
10% for (any one of) the histogram bins.
11%
12% How does this differ from MatLab's HIST function? This function:
13% - allows uniformly spaced bins only.
14% +/- operates on all elements of MTX, instead of columnwise.
15% + is much faster (approximately a factor of 80 on my machine).
16% + allows specification of number of bins OR binsize. Default=101 bins.
17% + allows (optional) specification of binCenter.
18
19% Eero Simoncelli, 3/97.
20
21function [N, X] = histo(mtx, nbins, binCtr)
22
23%% NOTE: THIS CODE IS NOT ACTUALLY USED! (MEX FILE IS CALLED INSTEAD)
24
25%fprintf(1,'WARNING: You should compile the MEX version of "histo.c",\n found in the MEX subdirectory of matlabPyrTools, and put it in your matlab path. It is MUCH faster.\n');
26
27mtx = mtx(:);
28
29%------------------------------------------------------------
30%% OPTIONAL ARGS:
31
32[mn,mx] = range2(mtx);
33
34if (exist('binCtr') ~= 1)
35 binCtr = mean(mtx);
36end
37
38if (exist('nbins') == 1)
39 if (nbins < 0)
40 binSize = -nbins;
41 else
42 binSize = ((mx-mn)/nbins);
43 tmpNbins = round((mx-binCtr)/binSize) - round((mn-binCtr)/binSize);
44 if (tmpNbins ~= nbins)
45 warning('Using %d bins instead of requested number (%d)',tmpNbins,nbins);
46 end
47 end
48else
49 binSize = ((mx-mn)/101);
50end
51
52firstBin = binCtr + binSize*round( (mn-binCtr)/binSize );
53
54tmpNbins = round((mx-binCtr)/binSize) - round((mn-binCtr)/binSize);
55
56bins = firstBin + binSize*[0:tmpNbins];
57
58[N, X] = hist(mtx, bins);