Get a 2D gaussian kernel for deconvolution
Hello,
I am trying to apply the Lucy-Richardson deconvolution algorithm with the following code:
static Mat RLTikh_deconvolution(Mat observed, Mat psf, int iterations) {
Mat deconv = observed.clone();
double mu = 0.01;
// Iterate
for (int i = 0; i < iterations; i++) {
// Temporary matrix
Mat ratio;
filter2D(deconv, ratio, deconv.depth(), psf, Point(-1, -1), 0,
BORDER_REFLECT);
divide(observed, ratio, ratio);
filter2D(ratio, ratio, ratio.depth(), psf, Point(-1, -1), 0,
BORDER_REFLECT);
// TV Regularization
Mat denom;
Laplacian(deconv, denom, deconv.depth(), 1, 1, 0, BORDER_REFLECT);
denom = 1.0 - 2.0 * mu * denom;
divide(ratio, denom, ratio);
// Apply iteration on the estimate
multiply(deconv, ratio, deconv);
}
return deconv;
}
I get the psf mat with Mat psf = getGaussianKernel(13, -1);
The problem is that this kernel is a 1D kernel but I would like to apply a 2D one. I believe I could apply the kernel two times (in X direction and Y direction) to get the result I want. But how I can do it ?