summaryrefslogtreecommitdiffstats
path: root/SD-VBS/benchmarks/texture_synthesis/src/matlab/mkGaussian.m
diff options
context:
space:
mode:
Diffstat (limited to 'SD-VBS/benchmarks/texture_synthesis/src/matlab/mkGaussian.m')
-rwxr-xr-xSD-VBS/benchmarks/texture_synthesis/src/matlab/mkGaussian.m58
1 files changed, 0 insertions, 58 deletions
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/mkGaussian.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/mkGaussian.m
deleted file mode 100755
index fa8a554..0000000
--- a/SD-VBS/benchmarks/texture_synthesis/src/matlab/mkGaussian.m
+++ /dev/null
@@ -1,58 +0,0 @@
1% IM = mkGaussian(SIZE, COVARIANCE, MEAN, AMPLITUDE)
2%
3% Compute a matrix with dimensions SIZE (a [Y X] 2-vector, or a
4% scalar) containing a Gaussian function, centered at pixel position
5% specified by MEAN (default = (size+1)/2), with given COVARIANCE (can
6% be a scalar, 2-vector, or 2x2 matrix. Default = (min(size)/6)^2),
7% and AMPLITUDE. AMPLITUDE='norm' (default) will produce a
8% probability-normalized function. All but the first argument are
9% optional.
10
11% Eero Simoncelli, 6/96.
12
13function [res] = mkGaussian(sz, cov, mn, ampl)
14
15sz = sz(:);
16if (size(sz,1) == 1)
17 sz = [sz,sz];
18end
19
20%------------------------------------------------------------
21%% OPTIONAL ARGS:
22
23if (exist('cov') ~= 1)
24 cov = (min(sz(1),sz(2))/6)^2;
25end
26
27if (exist('mn') ~= 1)
28 mn = (sz+1)/2;
29end
30
31if (exist('ampl') ~= 1)
32 ampl = 'norm';
33end
34
35%------------------------------------------------------------
36
37[xramp,yramp] = meshgrid([1:sz(2)]-mn(2),[1:sz(1)]-mn(1));
38
39if (sum(size(cov)) == 2) % scalar
40 if (strcmp(ampl,'norm'))
41 ampl = 1/(2*pi*cov(1));
42 end
43 e = (xramp.^2 + yramp.^2)/(-2 * cov);
44elseif (sum(size(cov)) == 3) % a 2-vector
45 if (strcmp(ampl,'norm'))
46 ampl = 1/(2*pi*sqrt(cov(1)*cov(2)));
47 end
48 e = xramp.^2/(-2 * cov(2)) + yramp.^2/(-2 * cov(1));
49else
50 if (strcmp(ampl,'norm'))
51 ampl = 1/(2*pi*sqrt(det(cov)));
52 end
53 cov = -inv(cov)/2;
54 e = cov(2,2)*xramp.^2 + (cov(1,2)+cov(2,1))*(xramp.*yramp) ...
55 + cov(1,1)*yramp.^2;
56end
57
58res = ampl .* exp(e);