summaryrefslogtreecommitdiffstats
path: root/SD-VBS/benchmarks/texture_synthesis/src/matlab/shrink.m
diff options
context:
space:
mode:
Diffstat (limited to 'SD-VBS/benchmarks/texture_synthesis/src/matlab/shrink.m')
-rwxr-xr-xSD-VBS/benchmarks/texture_synthesis/src/matlab/shrink.m25
1 files changed, 25 insertions, 0 deletions
diff --git a/SD-VBS/benchmarks/texture_synthesis/src/matlab/shrink.m b/SD-VBS/benchmarks/texture_synthesis/src/matlab/shrink.m
new file mode 100755
index 0000000..7af0151
--- /dev/null
+++ b/SD-VBS/benchmarks/texture_synthesis/src/matlab/shrink.m
@@ -0,0 +1,25 @@
1function ts=shrink(t,f)
2
3% It shrinks an image in a factor f
4% in each dimension.
5% ts = shrink(t,f)
6% ts may also be complex.
7% See also: expand.m, blurDn.m
8% JPM, April 95, Instituto de Optica, CSIC, Madrid.
9
10[my,mx]=size(t);
11T=fftshift(fft2(t))/f^2;
12Ts=zeros(my/f,mx/f);
13y1=my/2+2-my/(2*f);
14y2=my/2+my/(2*f);
15x1=mx/2+2-mx/(2*f);
16x2=mx/2+mx/(2*f);
17Ts(2:my/f,2:mx/f)=T(y1:y2,x1:x2);
18Ts(1,2:mx/f)=(T(y1-1,x1:x2)+T(y2+1,x1:x2))/2;
19Ts(2:my/f,1)=(T(y1:y2,x1-1)+T(y1:y2,x2+1))/2;
20Ts(1,1)=(T(y1-1,x1-1)+T(y1-1,x2+1)+T(y2+1,x1-1)+T(y2+1,x2+1))/4;
21Ts=fftshift(Ts);
22ts=ifft2(Ts);
23if all(imag(t)==0),
24 ts = real(ts);
25end