压缩感知 - 为什么当我给它*更多*样本时我的凸求解器会失败?

问题描述

我正在尝试使用 cvx library for MATLAB 实现图像的压缩感知。 这与 Steve Brunton 在他的示例 here 中使用的库相同。我的测试图像是 Lenna

这是我的 MATLAB 脚本:

close all; clear; clc

% read in an image
lenna = imread('lenna.png');
X = lenna(:,:,2); % greem channel only
X = X(200:249,100:149); % just a chunk
M = size(X,1); N = size(X,2);
x = vectorify(X);

figure,subplot(1,3,1),imshow(X),title(strcat("Original Image: ",num2str(M)," by ",num2str(N)," Pixels"))

% Sample randomly
K = 80; %number of random sampled pixels
c = randsample(numel(X),K); %locations of pixels as a list
y = x(c); %values
C = zeros(K,numel(X)); %C(c) = y;%(1:K);
Y = zeros(M,N); % there must be a more elegant way to do this...
for k=1:K
    C(k,c(k)) = y(k);
    Y2 = rectanglefy(C(k,:),M,N);
    Y=Y+Y2;
end
% Y=rectanglefy(C,N)
C = C>0; %convert C to a binary matrix
C = double(C); %cast
subplot(1,2),imshow(Y/255),title(strcat(num2str(K),' Sampled Pixels'))


% Solve for sparse representation
psi = dftmtx(M*N); psi=real(psi);
Theta = C*psi; n = M*N;

Theta = double(Theta); y = double(y); %cast required
cvx_begin;
    variable s_L1(n)
    minimize( norm(s_L1,1) );
    subject to
        Theta * s_L1 ==y; 
cvx_end

xr = psi*s_L1;
Xr = rectanglefy(xr,N);
subplot(1,3),imshow(Xr/255),title('Reconstructed Image')

function x = vectorify(X)
    x = reshape(X,[numel(X),1]);
end

function X = rectanglefy(x,N)
    X = reshape(x,[M,N]);
end

当我用 K=80 运行它时,它能够重建图像,尽管它当然不是很接近真实的东西:

Image reconstruction of 50x50 pixels,with 80 randomly sampled pixels.

但是,如果我将样本数量增加到 800 - 我希望这会使结果更接近 - 求解器告诉我这是不可行的:

Attempted image reconstruction with 800 randomly sampled pixels,and text from cvx solver in command window stating that solving is infeasible.

在两者之间,如果我将 K 设置为 180 个随机样本,求解器会产生“失败”,这显然与“不可行”的结果不同:

Attempted image reconstruction with 180 randomly sampled pixels,and text from cvx solver in command window stating that solving failed.

我不确定问题是出在我的代码中还是出在我对凸优化的(相当差的)理解中,但我的问题是:(a) 为什么会发生这种情况? (b) 我应该采取什么不同的方式来重建这张图片?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)