使用@Shai 的相关建议,我现在可以给出详细的答案。
我建议的选项 2 和 3 实际上是相同的,并且显然是正确的方法。这也是@Shai 链接的建议论文的 E 步骤中所做的。提出过度约束问题实际上非常简单。
为了正确地提出这些方程,我们使用这样一个事实,即每个块的点积(内核大小以某个像素为中心)G
与 180 度旋转版本h
应该等于对应的像素 in B
。这直接源于这样一个事实,即B
和G
与卷积相关,因此块通过互相关(以及因此 180 度旋转)G
与像素相关。B
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
。