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/shrink.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/shrink.m')
-rwxr-xr-x | SD-VBS/benchmarks/texture_synthesis/src/matlab/shrink.m | 25 |
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 @@ | |||
1 | function 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); | ||
11 | T=fftshift(fft2(t))/f^2; | ||
12 | Ts=zeros(my/f,mx/f); | ||
13 | y1=my/2+2-my/(2*f); | ||
14 | y2=my/2+my/(2*f); | ||
15 | x1=mx/2+2-mx/(2*f); | ||
16 | x2=mx/2+mx/(2*f); | ||
17 | Ts(2:my/f,2:mx/f)=T(y1:y2,x1:x2); | ||
18 | Ts(1,2:mx/f)=(T(y1-1,x1:x2)+T(y2+1,x1:x2))/2; | ||
19 | Ts(2:my/f,1)=(T(y1:y2,x1-1)+T(y1:y2,x2+1))/2; | ||
20 | Ts(1,1)=(T(y1-1,x1-1)+T(y1-1,x2+1)+T(y2+1,x1-1)+T(y2+1,x2+1))/4; | ||
21 | Ts=fftshift(Ts); | ||
22 | ts=ifft2(Ts); | ||
23 | if all(imag(t)==0), | ||
24 | ts = real(ts); | ||
25 | end | ||