%% MATH3360 Hw4 Image filtering in frequency domain
% In your script, you should have at least four functions, namely dft.m,
% idft.m, LPBufilter.m and HPBufilter.m for the discrete Fourier transform, 
% the inverse discrete Fourier transform,the low-pass Butterworth filter 
% and high-pass Butterworth filter respectively.
clear all
I=imread('cam.png');
I=double(I);
% Multiply $I(x,y)$ by $(-1)^{x+y}$
% Apply DFT



%-----------------
% Butterworth low-pass filter with n=2
% Multiply I with the filter by point-wise multiplication to obtain G
% Compute inverse DFT of G
% Take real part
% Multiply $G(x,y)$ by $(-1)^{x+y}$





imwrite(uint8(G),'Q4bi.png')
%--------------------
% Butterworth low-pass filter with n=20
% Multiply I with the filter by point-wise multiplication to obtain G
% Compute inverse DFT of G
% Take real part
% Multiply $G(x,y)$ by $(-1)^{x+y}$






imwrite(uint8(G),'Q4bii.png')
%--------------------
%Butterworth low-pass filter with n=200
% Multiply I with the filter by point-wise multiplication to obtain G
% Compute inverse DFT of G
% Take real part
% Multiply $G(x,y)$ by $(-1)^{x+y}$






imwrite(uint8(G),'Q4biii.png')
%--------------------
%Butterworth high-pass filter with n=2
% Multiply I with the filter by point-wise multiplication to obtain G
% Compute inverse DFT of G
% Take real part
% Multiply $G(x,y)$ by $(-1)^{x+y}$






imwrite(uint8(G),'Q4ci.png')
%--------------------
%Butterworth high-pass filter with n=20
% Multiply I with the filter by point-wise multiplication to obtain G
% Compute inverse DFT of G
% Take real part
% Multiply $G(x,y)$ by $(-1)^{x+y}$







imwrite(uint8(G),'Q4cii.png')
%--------------------
%Butterworth high-pass filter with n=200
% Multiply I with the filter by point-wise multiplication to obtain G
% Compute inverse DFT of G
% Take real part
% Multiply $G(x,y)$ by $(-1)^{x+y}$







imwrite(uint8(G),'Q4ciii.png')