Take an image $f$ with some characters on it (below, hjFu3). Let's apply a filter $h$ on it to obtain a second image $g$ where the text is not visible.

Is there a way to compute what kind of filter $h$ we have applied ? The aim being that this filter should be applied to decode a new blurred image that was blurred with the same filter $h$.

Some remarks :

- Let $\hat f=\text{fft}(f)$. I computed $\hat f$ and $\hat g$. Then $\hat h = \hat g / \hat f$ (pointwise) and then we can compute the $h$ by inverse fft. - I noticed that $g-f$ gives a image which is readable and I think I should exploit this fact because I can't explain why I should obtain a readable image.

I know that I should use a deconvolution algorithm. The point is I don't know the PSF function, so a blind algorithm could the solution. However I don't have any success using typical blind deconvolution algorithm of matlab.

I would like to know if we can compute the psf function given that we have the orignal and final image.

Data for the problem :

$f=$original image f

$\qquad \quad \large \downarrow PSF ?$

$g=$blurred image g

  • $\begingroup$ I don't that you can do it, in general. Let's consider a filter that averages all the values on the image, what would you do in that case? $\endgroup$ – nicoguaro Sep 20 '19 at 19:01
  • $\begingroup$ I tried some some blind deconvolution algorithms without success $\endgroup$ – Smilia Sep 21 '19 at 16:25
  • $\begingroup$ I agree with @nicoguaro that this seems unlikely to be solved without some assumptions or more data. If you had a lot of input-output image samples, you could perhaps find an operator to go from the output blurred image to the input one, but not sure if that's an option. $\endgroup$ – spektr Oct 4 '19 at 5:31
  • $\begingroup$ I assume you have both input image f and output image g and want to compute (or estimate) the filter h. Blind deconvolution (en.wikipedia.org/wiki/Blind_deconvolution ) is for trying to reconstruct the input image f and is a much harder problem. $\endgroup$ – SolverWorld Nov 11 '19 at 0:22

Assuming that the filter is a linear FIR filter and you know (or choose) the size of the filter, this can be solved the following way.

We have a known image f and an output image g, and we want to determine what filter h takes f->g.

For concreteness, let's assume that the filter is 5x5 filter, although the method applies to any other size. The problem is then to determine the 25 filter coefficients. Each point in the output image is thus a linear combination of 25 input points (known). Thus we have 25 unknowns and a number of equations equal to the number of pixels in g (which should be same as f). There will be uncertainty in pixels near the edge, where you will have to make decisions about what algorithm was used (assume zeros beyond the edge, copy pixels, etc.).

If the images are sufficiently large, this is in general solvable (degenerate cases obviously exist where you do not have enough independent data, such as an image with constant values).

More specifically, you can set up a linear equation to solve


where the unknowns $x \in \mathbb{R}^{25}$ are the 25 values in the filter h, $b \in \mathbb{R}^n$ are the values of pixels in the output image arranged in a one-dimensional vector, and $A \in \mathbb{R}^{n \times 25}$ has the values of the input input image arranged in rows. Each row has the 25 pixels that correspond to the input to the filter for outputting that row. That is, the ith row has the 25 pixels that used in computing the ith output pixel (in vector b).

Then you solve that with $x=A\setminus b$ in MATLAB or octave, or numpy.linalg.lstsq in numpy.

You can see how accurately your filter works by comparing $Ax$ with $b$ and perhaps displaying in an image format.

| cite | improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.