% Matching Process
clear
% Test Pattern  (Grating)
clear;
W=128; %‰¡•�
H=256; %�c•�
I1=zeros(H,W);
 
I_center=128;
I_mod=128;


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

for x=1:W;
    for y=1:H;
        r=sqrt(((x-64)/W)^2+((y-300)/H)^2);
        I1(y,x)=I_center+I_mod*cos((2*pi*f_start+pi*f_w*r^2));
    end
end
figure(1)
imagesc(I1,[0,256]);colormap(gray)
imwrite(I1/256,'sim_fing1.bmp');

% 10 pixel moving
I2=zeros(H,W);

for x=1:W;
    for y=1:H;
        r=sqrt(((x-74)/W)^2+((y-300)/H)^2);
        I2(y,x)=I_center+I_mod*cos((2*pi*f_start+pi*f_w*r^2));
    end
end
figure(2)
imagesc(I2,[0,256]);colormap(gray)
imwrite(I2/256,'sim_fing2.bmp');

% rotation 10 degree

theta=10;
th=theta/180*pi;

I3=zeros(H,W);

for x=1:W;
    for y=1:H;
        rx=x*cos(th)+y*sin(th);
        ry=-x*sin(th)+y*cos(th);
        r=sqrt(((rx-74)/W)^2+((ry-300)/H)^2);
        I3(y,x)=I_center+I_mod*cos((2*pi*f_start+pi*f_w*r^2));
    end
end
figure(3)
imagesc(I3,[0,256]);colormap(gray)
imwrite(I3/256,'sim_fing3.bmp');

