matlaboptimizationcvx

l1 magic error - matlab


I am trying to reconstruct the image using fewer observations than the dimensions of the signal(compressed sensing). I am trying to run the following piece of code -

A = imread('cameraman.png');

x_i = 37;
y_i = 95;
s = 35;

A = A([x_i:x_i+s],[y_i:y_i+s]);
x = double(A(:));
figure(1),imshow(A)
xlabel('original')
n=length(x);
m=floor(n/3);
Phi=randn(m,n);   %Measurment Matrix
Psi=dftmtx(n);   %sensing Matrix( or can be dct(eye(n)) )
y=Phi*x;  %compressed signal
Theta=Phi*Psi;
%Initial Guess:  y=Theta*s => s=Theta\y
s2=Theta\y;
%Solution
s1=l1qc_logbarrier(s2, Theta,[], y, 1e-1, 1e-1);
%Reconstruction
x1=Psi*s1;
figure,imshow(reshape(x1,size(A)), [0 256] ),xlabel('OMP')

However on running the code I get the following error.

Error using linsolve
Matrix must be positive definite.

Error in l1qc_newton (line 92)
    [dx,hcond] = linsolve(H11p, w1p, opts);

Error in l1qc_logbarrier (line 104)
  [xp, up, ntiter] = l1qc_newton(x, u, A, At, b, epsilon, tau, newtontol,
  newtonmaxiter, cgtol, cgmaxiter);

Error in cs_image2 (line 23)
s1=l1qc_logbarrier(s2, Theta,[], y, 1e-1, 1e-1);

The above piece of code recovers the solution when the sensing matrix is the dct matrix instead of dft matrix. Could someone point me to where the error lies? Is it a problem inherent to l1-magic? Will using a different solver work for me?

Note: l1qc_logbarrier is a function from the library l1 magic. http://users.ece.gatech.edu/justin/l1magic/index.html

l1qc_logbarrier solves -

l1 minimization


Solution

  • The error seems to have come because of using the dftmtx which outputs a matrix whose elements are complex numbers and l1-magic doesn't work for that case. The problem I was trying to solve is l1-minimization -

    enter image description here

    Here psi is complex. So l1-magic fails. To get over it, I made the following adjustments. Let enter image description here , where R is the real and C the imaginary part of psi and similarly, let enter image description here. This gives,

    enter image description here

    We know that b is real, therefore,

    enter image description here

    Merging the 2 constraints, we get,

    enter image description here

    This gives us a single real constraint of the form enter image description here which can be solved using l1-magic.