close all
% ucitamo sliku
[img,map]=imread('angio0.tif');
figure(1)
imagesc(img)
colormap(gray)
imgFT = fft2(img);

%zasumljna slika
imgGN=imnoise(img,'gaussian'); % dodajemo bijeli šum
figure(2)
imagesc(imgGN)
colormap(gray)
var  = 0.01; % default value
%J = IMNOISE(I,'gaussian',M,V) adds Gaussian white noise of mean M and
%    variance V to the imagesc I. When unspecified, M and V default to 0 and
%    0.01 respectively.
imgGN_FT = fft2(imgGN);

%izracun wienerovog filtra
wiener = imgFT.^2./(imgFT.^2 + var^2);

%max(max(abs(wiener)))
figure(3)
imagesc(abs(wiener))
colormap(gray)
% abs(wiener)
izlazFT = wiener.*imgGN_FT;
izlaz = ifft2(izlazFT);
figure(4)
imagesc(abs(izlaz))
colormap(gray)

% snri = snr(double(img),double(imgGN));
% snro = snr(double(img),double(izlaz));

snri = 10*log10(sum(sum(abs(imgFT).^2))/sum(sum(abs(fft2(double(imgGN)-double(img))).^2)));
snro = 10*log10(sum(sum(abs(imgFT).^2))/sum(sum(abs(fft2(abs(izlaz)-double(img))).^2)));




