%DIP  Class Demo
%Shreekanth Mandayam, Rowan University
%
function [Hhp,filtered] = highpassf(original,cutoff)

%This function performs ideal lowpass filtering
%in the frequency domain by generating a circularly
%symmetric highpass filter.

%Display original image
close all;
N=length(original);
imshow(mat2gray(original));
title('Original');
pause;

%FFT of original image
figure;
imshow(mat2gray(fftshift(log(1+abs(fft2(original))))));
title('Log Magnitude of FFT of Original');
pause;


[f1,f2]=freqspace(N);
[f1,f2]=meshgrid(f1,f2);
Hhp=ones(N,N);d=find(sqrt(f1.^2+f2.^2) < cutoff);
Hhp(d)=zeros(size(d));
figure;
imshow(Hhp);
title('Freq Domain Filter');
pause;

Filtered=fft2(original).*fftshift(Hhp);
figure;
imshow(mat2gray(fftshift(log(1+abs(Filtered)))));
title('Log Magnitude of FFT of Filtered');
pause;


filtered=abs(ifft2(Filtered));
filtered=mat2gray(filtered);
figure;clf;
imshow(filtered);
title('Filtered');
