Unlike the standard (and more challenging) de-blurring and super resolution scenarios, I have access to both the original (sharp) image G
and it's blurred version B
. I'm simply looking for the blur kernel h
. So because B
is taken using a real camera the relation is:
B=G*h+N
(where *
denotes convolution and N
is some additive noise)
Naturally, this is an over-constrained problem since h
is small in size compared to G
and B
and so every few pixels in the pair of images generate an equation on the entries of h
.
But what would be the simplest way to actually implement this? My thoughts so far:
- Moving to the frequency domain and doing division (as this answer suggests). But this would be inevitably numerically unstable because of the noise right?
- Cross-correlation - I've only found examples for 1-D signals and couldn't figure out how to use in the 2D case of images.
- Carefully constructing an over-constrained linear system
G'h'=B'
looking forh'
which is a vector version of the entries of the kernelh
using some optimization procedure. But this is very tedious and the matrixG'
and vectorB'
are bound to be huge in size.
A concrete example in any programming language from C++ to MATLAB would be extremely useful.
Using @Shai's relevant suggestion, I can now give the detailed answer.
Options 2 and 3 that I suggested are in fact the same and are apparently the right way to go. It is also what was done in the E-step of the suggested paper linked by @Shai. Posing the over constrained problem is in fact quite simple.
To correctly pose these equations we use the fact that the dot product of every block the size of the kernel centered around some pixel in
G
with the 180 degrees rotated version ofh
should equal the corresponding pixel inB
. This is directly derived from the fact thatB
andG
are related by convolution and so blocks inG
relate to pixels inB
by cross-correlation (and hence the 180-degree rotation).The MATLAB code now becomes:
I also found that some constraints over the solution may be necessary for practical scenarios. Examples are enforcing the kernel to be positive, smooth, or symmetric. The exact method of incorporating these is out of the scope of this question but will usually come in the shape of a linear constraint or a regularization element when solving for
vXcorrKer
.