1. Weiner Deconvolution Using 1/f Law:

function f0 = zDeconvWNR(f, k, C)
% This is the Weiner deconvolution algorithm using 1/f law
% f: defocused image
% k: defocus kernel
% C: sigma^2/A: see a demo of using C in zDemo.m

[hei, wid] = size(f);
k = zPSFPad(k, hei, wid);
k = fft2(fftshift(k));
f0 = abs(ifft2((fft2(f).*conj(k))./(k.*conj(k) + C)));

%===Sub Functions=====

function outK = zPSFPad(inK, hei, wid);
% This function is to zeropadding the psf
[shei, swid] = size(inK);
outK = zeros(hei, wid);
outK(floor(end/2-shei/2)+1:floor(end/2-shei/2)+shei, floor(end/2-swid/2)+1:floor(end/2-swid/2)+swid) = inK;

2. Pattern Evaluation with respect to defocus deblurring -- a demo of the code

All the codes and data required to repeat the following evaluation is here: zDemo.m, eMakePrior.m, data.zip. This is also a demo of the Weiner deconvolution algorithm using 1/f law



****   Evaluate Coded Apertures with Respect to Defocus Deblurring    ****





 - This simulation evaluate four patterns:
   Circular pattern, [Levin 2007], [Veeraraghavan 2008], [Zhou 2009]
 - This is also a demo code of Weiner Deconvolution Algorithm using 1/f Law [Zhou, ICCP 2009]
 - written by Changyin Zhou @ Columbia U, 2009'

Set Parameters

Noise level = 0.005; Blur size = 7

Read Image

Prepare the prior matrix: 1/f law

For specific scenes, suggest to use related images to generate the prior matrix, A

Circular Pattern

Levin's Pattern, [Levin, Siggraph 2007].

Note, this pattern is designed for DFD

Veeraraghavan's Pattern [Veeraraghavan, Siggraph 2008]

Zhou's Patterns, [Zhou, ICCP 2009]

This is one of the optimized patterns in [Zhou, ICCP 2009]