Denoising and deblurring an image containing K blurred lines

Contents

DATA GENERATION

clear all; close all;

Add current folder and all subfolders to the path

tmp=which('main');          % complete path to the main file
index=strfind(tmp,'/');     % index of '/' into the string tmp
p=tmp(1:index(end));        % folder which contains the file
addpath(genpath(p));        % add folder and its subfolders to the path
clear tmp p index           % clear these temporary variables

W=65;               % image width (must be odd W=2M+1)
H=65;               % image height
K=3;                % number of lines
spread=1;           % std of the gaussian blur
noiselevel=0;     % level of noise
randomgen=0;        % boolean if lines are generated randomly of manually
rng(0);             % seed of random numbers generator
plotData=1;         % display images v, x and y
plotComp=0;         % display others comparaisons theo vs. emp

t_k = zeros(1,K);   % array containing angles of lines
a_k = zeros(1,K);   % array containing amplitude of lines
p_k = zeros(1,K);   % array containing offset of lines
for k=1:K
    if randomgen
        t_k(k)=rand*pi/2-pi/4;       % angle varying between -pi/4 and pi/4
        a_k(k)=(0.2+0.7*rand)*255;   % amplitude varying between 0.2 and 1
        p_k(k)=rand*W-(W-1)/2;       % offset varying betweeen -M and M
    else
        t_k(k)=(-1)^k*pi/6;
        a_k(k)=255;
        p_k(k)=0;
    end
end

This has to be commented if you want to test with another number of lines and other parameters, possibly randoms.

t_k=[pi/6 -pi/5 pi/16];
a_k=[255 255 255];
p_k=[10 0 -15];

Generation of the data

data_generation;    % Generate the blurred image xstar
                    % of these K lines with additional
                    % noise y=xstar+randn(H,W)*noiselevel

MINIMIZATION ALGORITHM

Nbiter=2000;            % number of iterations
rho=1.9;                % weigth coefficient
tau=150000000;          % primal step (sigma is then computed from tau)
c=sum(a_k./cos(t_k));   % theoritical atomic norm of each line
plotError=1;            % compute and display error
displayIter=0;          % display the counter iteration
algo=2;                 % choose the minimization algorithm to use

switch algo
    case 2                      % Algorithm 2 find by minimization an
        minimization_Chambolle; % approximation wr of wstar which is the
                                % horizontal Fourier transform of the
                                % deblurred image sstar
    otherwise
        minimization_Condat;    % Algorithm 1 converges toward the same
                                % solution but is slower than Algorithm 2
                                % Note that it needs rho<=1 and tau<1.9
                                % For the given example take rho=1, tau=1.7
end
Elapsed time is 259.959483 seconds.

IMAGE RECONSTRUCTION AND LINES ESTIMATION

Reconstruct the denoised image xstar from wstar:

resynthesis;

Estimate lines parameters and display it

cstar=sum(a_k./cos(t_k));  % theoritical atomic norm of each line
coef=cstar/c;              % factor between experimental and true amplitude
prony;
thetamean = -0.62837     0.17872      0.5198
alphamean = 647.0155      642.9302      633.8648
eta = -0.179142     -14.9009      10.2207
(thetamean-t_k)/t_k = 8.7911e-05   -0.089811  -0.0072628
(alphamean*coef-a_k)/a_k = 0.012517   0.0061234  -0.0080631
eta-p_k = -0.17914    0.099138     0.22073