 % Test Pattern  (Grating)
clear;
W=512; %‰¡•�
H=512; %�c•�
I1=zeros(H,W);
 
I_width=255;
I_mod=128;


f_start=0; % �Å’á‹óŠÔŽü”g�”
f_stop=20; % �Å�‚‹óŠÔŽü”g�” cycle/W
f_w=f_stop-f_start;

for x=1:W;
    for y=1:H;
        r=sqrt(((x-1)/W)^2+((y-1)/H)^2);
        I1(y,x)=I_width*round(0.5+0.5*cos((2*pi*f_start+pi*f_w*r^2)));
    end
end
figure(1)
imagesc(I1,[0,256]);colormap(gray)

I2=fft2(I1);I2=fftshift(I2);
I3=20*log10(abs(I2));

figure(2)
imagesc(I3); colormap(gray)

f_cut=0.3;
I_mask=ones(H,W);
for x=1:W;
    for y=1:H;
        r=sqrt(((x-256)/W)^2+((y-256)/H)^2);
        if r<f_cut
            I_mask(y,x)=0;
        else
            I_mask(y,x)=1;
        end;
     end
end

I2=I2.*I_mask;
I4=ifft2(I2);
I4=abs(I4);
figure(3)
imagesc(I4);colormap(gray)

 
