%
%   Purpose: Butterworth High Pass Filtering (BHPF)
%   Written by: H.E.
%   Date: 2/09
%

close all;
im=imread('Loop.jpg'); im=double(im(:,:,1));
[M,N]=size(im); P=2*M; Q=2*N; n=4; D0=50;
fp=zeros(P,Q); fp(1:M,1:N)=im;
subplot(2,2,1); imagesc(fp); colormap(gray); title('Thumb print');
[x,y]=meshgrid(1:Q,1:P); onemtx=repmat(-1,P,Q);
fp=fp.*(onemtx.^(x+y));
D=sqrt((x-Q/2).^2+(y-P/2).^2); H=1./((1+D0./D).^(2*n));
F=fft2(fp);
subplot(2,2,2); imagesc(H); colormap(gray); title('H(u,v)');
G=H.*F;
g=real(ifft2(G)).*(onemtx.^(x+y)); g=g(1:M,1:N);
subplot(2,2,3); imagesc(g); colormap(gray); title('High pass filtering with a BHPF');
g=g.*(g > 0);
subplot(2,2,4); imagesc(g); colormap(gray); title('Thumb print thresholded');


