# Revision history [back]

you can use sepFilter2D

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;
sepFilter2D(deconv, ratio, deconv.depth(), psf, psf, Point(-1, -1), 0,
BORDER_REFLECT);

divide(observed, ratio, ratio);

sepFilter2D(ratio, ratio, ratio.depth(), psf, 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;
}


you can use sepFilter2D with your 1d kernel:

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;
sepFilter2D(deconv, ratio, deconv.depth(), psf, psf, Point(-1, -1), 0,
BORDER_REFLECT);

divide(observed, ratio, ratio);

sepFilter2D(ratio, ratio, ratio.depth(), psf, 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;
}


you can use sepFilter2D with your 1d kernel:

I believe I could apply the kernel two times (in X direction and Y direction)

that's exactly, what it does.

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;
sepFilter2D(deconv, ratio, deconv.depth(), psf, psf, Point(-1, -1), 0,
BORDER_REFLECT);

divide(observed, ratio, ratio);

sepFilter2D(ratio, ratio, ratio.depth(), psf, 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;
}