% compute the average PSNR for the 68 Berkeley test images 
% the noise level sigma and the number of iterations can be changed below
% possible sigmas: 10,15,20,25,50
% possible niter: 1,2,3,4
sigma=25;
niter=1;
L=dlmread('test.txt');
n=size(L,1)
no=zeros(n,2);
p=load_arfmodel(sigma,niter);
savename=sprintf('arf_%d_%d.txt',sigma,niter)
for i=1:n
    name=sprintf('%d.png',L(i))
    im0=double(imread(name));
    im = im0 + sigma * randn(size(im0));
    io = denoise_arf(im, p);
    diff = double(io) - double(im0);
    psnr=20 * log10(255 / std(diff(:)))
    no(i,1)=L(i);
    no(i,2) = psnr;
    dlmwrite(savename,no);
end    
mean(no(:,2))
std(no(:,2))