clear all;
close all;

[A,MAP] = imread('man.bmp');
dpN = 3/10;
DPfilterSize = floor(size(A,1)*dpN/2);

hpN = 1/10;
HPfilterSize = floor(size(A,1)*hpN/2);

imshow(A); %figure 1

MAP = [];
for index=1:257
    MAP = [MAP;(index-1)/256 (index-1)/256 (index-1)/256];
end

%-------------------------------------------------------------
%Fourierka
%figure;
%imshow(A); %figure 2
FA = FFT2(A);
SFA = FFTSHIFT(FA);

figure;

%imshow(abs(SFA),MAP); %figure 3
figure;
%imshow(unwrap(angle(SFA)),MAP); %figure 4
%-------------------------------------------------------------

%DP filtracia
DP = zeros(size(A,1),size(A,2));
DP(size(A,1)/2-DPfilterSize:size(A,1)/2+DPfilterSize, size(A,2)/2-DPfilterSize:size(A,2)/2+DPfilterSize)=1;
%figure;
%imshow(DP); %figure 5

SFAF = SFA.*DP;
FAF = IFFTSHIFT(SFAF);
AF = IFFT2(FAF);
%figure;
%imshow(abs(AF),MAP); %figure 6

%HP filtracia
HP = ones(size(A,1),size(A,2));
HP(size(A,1)/2-HPfilterSize+1:size(A,1)/2+HPfilterSize+1, size(A,2)/2-HPfilterSize+1:size(A,2)/2+HPfilterSize+1) = 0;
%figure;
%imshow(HP); %figure 7

SFAF = SFA.*HP;
AF = IFFT2(SFAF);
%figure;
%imshow(abs(AF),MAP); %figure 8

for index1=1:256
    for index2=1:256
        FAshift(index1,index2) = SFA(index1,index2)*exp(-i*(100*2*pi/256)*index2)*exp(-i*(100*2*pi/256)*index1);
    end
end
AF = IFFT2(FAshift);
figure;
imshow(abs(AF),MAP); %figure 9
