diff options
author | leochanj105 <leochanj@live.unc.edu> | 2020-10-19 23:09:30 -0400 |
---|---|---|
committer | leochanj105 <leochanj@live.unc.edu> | 2020-10-20 02:40:39 -0400 |
commit | f618466c25d43f3bae9e40920273bf77de1e1149 (patch) | |
tree | 460e739e2165b8a9c37a9c7ab1b60f5874903543 /SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/histoMatch.m | |
parent | 47ced4e96bbb782b9e780e8f2cfc637b2c21ff44 (diff) |
initial sd-vbs
initial sd-vbs
add sd-vbs
sd-vbs
Diffstat (limited to 'SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/histoMatch.m')
-rwxr-xr-x | SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/histoMatch.m | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/histoMatch.m b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/histoMatch.m new file mode 100755 index 0000000..ab82782 --- /dev/null +++ b/SD-VBS/benchmarks/texture_synthesis/src/matlabPyrTools/histoMatch.m | |||
@@ -0,0 +1,35 @@ | |||
1 | % RES = histoMatch(MTX, N, X) | ||
2 | % | ||
3 | % Modify elements of MTX so that normalized histogram matches that | ||
4 | % specified by vectors X and N, where N contains the histogram counts | ||
5 | % and X the histogram bin positions (see histo). | ||
6 | |||
7 | % Eero Simoncelli, 7/96. | ||
8 | |||
9 | function res = histoMatch(mtx, N, X) | ||
10 | |||
11 | if ( exist('histo') == 3 ) | ||
12 | [oN, oX] = histo(mtx(:), size(X(:),1)); | ||
13 | else | ||
14 | [oN, oX] = hist(mtx(:), size(X(:),1)); | ||
15 | end | ||
16 | |||
17 | oStep = oX(2) - oX(1); | ||
18 | oC = [0, cumsum(oN)]/sum(oN); | ||
19 | oX = [oX(1)-oStep/2, oX+oStep/2]; | ||
20 | |||
21 | N = N(:)'; | ||
22 | X = X(:)'; | ||
23 | N = N + mean(N)/(1e8); %% HACK: no empty bins ensures nC strictly monotonic | ||
24 | |||
25 | nStep = X(2) - X(1); | ||
26 | nC = [0, cumsum(N)]/sum(N); | ||
27 | nX = [X(1)-nStep/2, X+nStep/2]; | ||
28 | |||
29 | nnX = interp1(nC, nX, oC, 'linear'); | ||
30 | |||
31 | if ( exist('pointOp') == 3 ) | ||
32 | res = pointOp(mtx, nnX, oX(1), oStep); | ||
33 | else | ||
34 | res = reshape(interp1(oX, nnX, mtx(:)),size(mtx,1),size(mtx,2)); | ||
35 | end | ||