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/matlab/mkFract.m | |
parent | 47ced4e96bbb782b9e780e8f2cfc637b2c21ff44 (diff) |
initial sd-vbs
initial sd-vbs
add sd-vbs
sd-vbs
Diffstat (limited to 'SD-VBS/benchmarks/texture_synthesis/src/matlab/mkFract.m')
-rwxr-xr-x | SD-VBS/benchmarks/texture_synthesis/src/matlab/mkFract.m | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/mkFract.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/mkFract.m new file mode 100755 index 0000000..af95cd5 --- /dev/null +++ b/SD-VBS/benchmarks/texture_synthesis/src/matlab/mkFract.m | |||
@@ -0,0 +1,36 @@ | |||
1 | % IM = mkFract(SIZE, FRACT_DIM) | ||
2 | % | ||
3 | % Make a matrix of dimensions SIZE (a [Y X] 2-vector, or a scalar) | ||
4 | % containing fractal (pink) noise with power spectral density of the | ||
5 | % form: 1/f^(5-2*FRACT_DIM). Image variance is normalized to 1.0. | ||
6 | % FRACT_DIM defaults to 1.0 | ||
7 | |||
8 | % Eero Simoncelli, 6/96. | ||
9 | |||
10 | %% TODO: Verify that this matches Mandelbrot defn of fractal dimension. | ||
11 | %% Make this more efficient! | ||
12 | |||
13 | function res = mkFract(dims, fract_dim) | ||
14 | |||
15 | if (exist('fract_dim') ~= 1) | ||
16 | fract_dim = 1.0; | ||
17 | end | ||
18 | |||
19 | res = randn(dims); | ||
20 | fres = fft2(res); | ||
21 | |||
22 | sz = size(res); | ||
23 | ctr = ceil((sz+1)./2); | ||
24 | |||
25 | shape = ifftshift(mkR(sz, -(2.5-fract_dim), ctr)); | ||
26 | shape(1,1) = 1; %%DC term | ||
27 | |||
28 | fres = shape .* fres; | ||
29 | fres = ifft2(fres); | ||
30 | |||
31 | if (max(max(abs(imag(fres)))) > 1e-10) | ||
32 | error('Symmetry error in creating fractal'); | ||
33 | else | ||
34 | res = real(fres); | ||
35 | res = res / sqrt(var2(res)); | ||
36 | end | ||