【问题标题】:How to implement regularized least squares in matlab如何在matlab中实现正则化最小二乘
【发布时间】:2014-01-09 18:24:45
【问题描述】:

我正在尝试在 Matlab 中实现论文减少图像反卷积中的边界伪影可用here

我遇到的问题是我不知道如何在 matlab 中实现论文中描述的正则化最小二乘问题。

谁能给我一些建议?直到现在我在matlab中找到了套索函数 但我不确定这是我需要的。谢谢你。

【问题讨论】:

  • 尝试以矩阵形式表达它,如min(|| X*w - Y || + k*||w||)等...

标签: matlab image-processing least-squares


【解决方案1】:
A=double(A);
[M,N]=size(A);
Dm=eye(M);
Dn=eye(N);
Dxx=diff(Dm,2,1); % 2nd derivative
Dyy=diff(Dn,2,1);
LA=kron(Dxx,Dn)+kron(Dm,Dyy); %Laplacian operator

I=eye(M*N);
A1=zeros(size(A)); 
A1(1:alpha,:)=1;  % alpha in formula (1) and (2) from paper, boundary margin
A1(M-alpha:M,:)=1; 
B1=zeros(size(B));     % B is A' in the formula
B1(1:alpha,:)=1;
B1(M:M+alpha,:)=1;   % B1 is A-A', boundary elements padded as the paper shows

H=[LA;sqrt(lambda)*I(A1,:)];  % consolidate the laplacian operator in the 1st part and the norm in the 2nd part 
y=[zeros(size(LA,1),1);B(B1)]; % convert the original problem to a matrix equation Hx=y
X=reshape(H\y, M,N);

【讨论】:

  • 定义A1后第二行有错误。请您也解释一下代码吗?
  • 我将优化形式转换为矩阵方程。基本上,如果你想优化 |ax-b|^2+|cx-d|^2,你就等价地求解 [a;c]x = [b;d]。这就是代码中 H 和 y 的形成方式。边界减法可能会进一步修改(可能在更好地理解论文之后),但提出了将优化处理为矩阵方程形式的基本方法
  • 另一个问题:Im 和 In(你的意思是 Dm 和 Dn)是谁?
  • @lennon310,这段代码确实需要解释——内联,而不是注释。
  • @A.Donda 谢谢唐达。在代码中添加了更多的 cmets。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-07-13
  • 2013-02-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-07-29
相关资源
最近更新 更多