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/common/toolbox/MultiNcut/fft_filt_2.m | |
| parent | 47ced4e96bbb782b9e780e8f2cfc637b2c21ff44 (diff) | |
initial sd-vbs
initial sd-vbs
add sd-vbs
sd-vbs
Diffstat (limited to 'SD-VBS/common/toolbox/MultiNcut/fft_filt_2.m')
| -rwxr-xr-x | SD-VBS/common/toolbox/MultiNcut/fft_filt_2.m | 29 |
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 @@ | |||
| 1 | function 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); | ||
| 13 | I=zeros(size(V)+[M1-1 M2-1]); | ||
| 14 | I(1:N1,1:N2)=V; | ||
| 15 | N1s=length(1:sf:N1); | ||
| 16 | N2s=length(1:sf:N2); | ||
| 17 | IF=fft2(I); | ||
| 18 | FI=zeros(N1s,N2s,N3); | ||
| 19 | |||
| 20 | % apply filters | ||
| 21 | for 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); | ||
| 28 | end | ||
| 29 | |||
