计算两幅图像之间的模糊内核

2024-01-11

与标准(且更具挑战性)去模糊和超分辨率场景不同,我可以访问原始(清晰)图像G而且是模糊版本B。我只是在寻找模糊内核h。所以因为B使用真实相机拍摄,关系为:

B=G*h+N(在哪里*表示卷积和N是一些附加噪声)

自然,这是一个过度约束的问题,因为h尺寸较小G and B因此,这对图像中的每隔几个像素都会生成一个关于以下条目的方程h.

但实际实现这一点的最简单方法是什么?到目前为止我的想法:

  • 移动到频域并进行除法(如这个答案 https://stackoverflow.com/questions/5972952/the-blurring-kernel-of-a-low-quality-camera建议)。但由于噪声的原因,这将不可避免地在数值上不稳定,对吗?
  • 互相关 - 我只找到了一维信号的示例,无法弄清楚如何在图像的二维情况下使用。
  • 精心构建超约束线性系统G'h'=B'寻找h'这是内核条目的向量版本h使用一些优化程序。但这非常乏味并且矩阵G'和矢量B'规模必然是巨大的。

从 C++ 到 MATLAB 的任何编程语言的具体示例都非常有用。


使用@Shai的相关建议,我现在可以给出详细的答案。

我建议的选项 2 和 3 实际上是相同的,并且显然是正确的方法。这也是@Shai 链接的建议论文的 E 步中所做的事情。提出过度约束问题实际上非常简单。

为了正确地提出这些方程,我们使用以下事实:每个块的点积(内核大小以某个像素为中心)G180 度旋转版本h应该等于相应的像素B。这直接源于以下事实:B and G通过卷积相关,因此块G与像素相关B通过互相关(因此 180 度旋转)。

MATLAB 代码现在变为:

%inputs: B,G - gray level blurred and sharp images respectively (double)
%        szKer - 2 element vector specifying the size of the required kernel
%outputs: mKer - the recovered kernel, 
%         imBsynth - the sharp image convolved with the recovered kernel
%
%example usage:  mKer = calcKer(B, G, [11 11]);

function [mKer, imBsynth] = calcKer(B, G, szKer)

  %get the "valid" pixels from B (i.e. those that do not depend 
  %on zero-padding or a circular assumption
  imBvalid = B(ceil(szKer(1)/2):end-floor(szKer(1)/2), ...
      ceil(szKer(2)/2):end-floor(szKer(2)/2));

  %get a matrix where each row corresponds to a block from G 
  %the size of the kernel
  mGconv = im2col(G, szKer, 'sliding')';

  %solve the over-constrained system using MATLAB's backslash
  %to get a vector version of the cross-correlation kernel
  vXcorrKer = mGconv \ imBvalid(:);

  %reshape and rotate 180 degrees to get the convolution kernel
  mKer = rot90(reshape(vXcorrKer, szKer), 2);

  if (nargout > 1)
      %if there is indeed a convolution relationship between B and G
      %the following will result in an image similar to B
      imBsynth = conv2(G, mKer, 'valid');
  end

end

我还发现,对于实际场景来说,对解决方案的一些限制可能是必要的。例如强制内核为正、平滑或对称。合并这些的确切方法超出了这个问题的范围,但在求解时通常会以线性约束或正则化元素的形式出现vXcorrKer.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

计算两幅图像之间的模糊内核 的相关文章