]> AND Private Git Repository - these_gilles.git/blob - THESE/codes/graphe/Ncut_9/fft_filt_2.m
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
3 sep
[these_gilles.git] / THESE / codes / graphe / Ncut_9 / fft_filt_2.m
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 % Jianbo Shi, 1997
10
11 [M1,M2,N3]=size(FB);
12 % prepare FFT of image for filtering
13 [N1,N2]=size(V);
14 I=zeros(size(V)+[M1-1 M2-1]);
15 I(1:N1,1:N2)=V;
16 N1s=length(1:sf:N1);
17 N2s=length(1:sf:N2);
18 IF=fft2(I);
19 FI=zeros(N1s,N2s,N3);
20
21 % apply filters
22 for n=1:N3;
23    f=rot90(FB(:,:,n),2);
24    fF=fft2(f,N1+M1-1,N2+M2-1);
25    IfF=IF.*fF;
26    If=real(ifft2(IfF));
27    If=If(ceil((M1+1)/2):ceil((M1+1)/2)+N1-1,ceil((M2+1)/2):ceil((M2+1)/2)+N2-1);
28    FI(:,:,n)=If(1:sf:N1,1:sf:N2);
29 end
30