summaryrefslogtreecommitdiffstats
path: root/SD-VBS/common/toolbox/MultiNcut/fft_filt_2.m
diff options
context:
space:
mode:
authorLeo Chan <leochanj@live.unc.edu>2020-10-22 01:53:21 -0400
committerJoshua Bakita <jbakita@cs.unc.edu>2020-10-22 01:56:35 -0400
commitd17b33131c14864bd1eae275f49a3f148e21cf29 (patch)
tree0d8f77922e8d193cb0f6edab83018f057aad64a0 /SD-VBS/common/toolbox/MultiNcut/fft_filt_2.m
parent601ed25a4c5b66cb75315832c15613a727db2c26 (diff)
Squashed commit of the sb-vbs branch.
Includes the SD-VBS benchmarks modified to: - Use libextra to loop as realtime jobs - Preallocate memory before starting their main computation - Accept input via stdin instead of via argc Does not include the SD-VBS matlab code. Fixes libextra execution in LITMUS^RT.
Diffstat (limited to 'SD-VBS/common/toolbox/MultiNcut/fft_filt_2.m')
-rwxr-xr-xSD-VBS/common/toolbox/MultiNcut/fft_filt_2.m29
1 files changed, 29 insertions, 0 deletions
diff --git a/SD-VBS/common/toolbox/MultiNcut/fft_filt_2.m b/SD-VBS/common/toolbox/MultiNcut/fft_filt_2.m
new file mode 100755
index 0000000..9c84e96
--- /dev/null
+++ b/SD-VBS/common/toolbox/MultiNcut/fft_filt_2.m
@@ -0,0 +1,29 @@
1function FI=fft_filt_2(V,FB,sf);
2% FI=fft_filt_2(V,FB,sf);
3% fft-based filtering
4% requires image to be called "V"
5% and filters to be in FB
6% sf is the subsampling factor
7%
8% FI is the result
9
10[M1,M2,N3]=size(FB);
11% prepare FFT of image for filtering
12[N1,N2]=size(V);
13I=zeros(size(V)+[M1-1 M2-1]);
14I(1:N1,1:N2)=V;
15N1s=length(1:sf:N1);
16N2s=length(1:sf:N2);
17IF=fft2(I);
18FI=zeros(N1s,N2s,N3);
19
20% apply filters
21for n=1:N3;
22 f=rot90(FB(:,:,n),2);
23 fF=fft2(f,N1+M1-1,N2+M2-1);
24 IfF=IF.*fF;
25 If=real(ifft2(IfF));
26 If=If(ceil((M1+1)/2):ceil((M1+1)/2)+N1-1,ceil((M2+1)/2):ceil((M2+1)/2)+N2-1);
27 FI(:,:,n)=If(1:sf:N1,1:sf:N2);
28end
29