2019-06-10
Let's talk about image restoration. It is a fun topic when you understand the intuition.
Say you asked a friend to take a picture of you in front of Lake Geneva. But due to his shaky hands, a blurry bad image was produced.
That's quite sad, since you know the image you wanted should have looked like this:
Now the question is, is it possible to restore the unwanted effects from the bad image, such that we get the good image? Well first, let's understand how we can model the relation between the ideal image (good image) and the observed image (bad image). Let the mistake and the blur induced by the photographer be modeled by a convolution with a degradation filter and noise. Let represent the degradation filter with the assumption that it is a linear low pass filter and represent the noise with the assumption that it is additive.
We essentially want to find a filter that will undo the convolution above. We want to find a restoration filter that when convolved with the observed image, produces the ideal image. So the restored image will be:
Let's substitute from the model to the above equation:
Let's change the representation to the Fourier domain, so multiplication will take the place of convolution. So the Fourier transform of the restored image will be the Fourier transform of the ideal image multiplied with the Fourier transform of the degradation filter plus noise, all multiplied by the Fourier transform of the restoration filter:
Now do you see what might be a good idea for the restoration filter ? It is exactly the inverse filter. Do you see why it is called the inverse filter?
This means that if we know or an approximation of it, we can build an inverse filter to restore our observed image. Thus with substitution of , the spectrum of the restored image will be:
Well this is great since the equation above shows that the restored image is really just the ideal image plus some high pass noise and that the restored image approaches the ideal image when noise is low. This means that the inverse filter can be a very good solution to our problem!
However, what if the noise is large? Then wouldn't increase and corrupt our image?...
When using the inverse filter on images where there is no noise, the image restoration would be perfect. However, the problem is that when there is noise, the noise will be amplified. This is why will look at the Weiner filter, which is a type of adaptive filter. The difference between the inverse and the Weiner filters is that the inverse filter disregard the noise, while the Weiner filter considers a model of both the image and the noise.
The Weiner filter aims to find a such that the error between the restored image and the ideal image is minimal:
In order to solve for , we can take the derivative of the error with respect to and set it to zero. Remember, is in the term in the error equation since is convolved with . Without going into the derivation of as it simply involves taking derivatives, below is the solution , the Weiner filter, in the Fourier domain:
where is the power interspectrum, which is related to the complex conjugate of the degradation filter and the power spectrum of the ideal image. is the power spectrum of , which is related to the power spectrum of the noise and the power spectrum of the ideal image. When the noise is additive, we can write and as:
Finally, is as follows:
We can see from the equation above that the Wiener filter has two separate part, an inverse filtering part and a noise smoothing part. It not only performs the deconvolution by inverse filtering (highpass filtering) but also removes the noise with a compression operation (lowpass filtering).
More intuitively, the Weiner filter does this: for each frequency, we can estimate if the power of the noise is significant in respect to the power of the image in order to see whether it is a good idea to use the inverse filter or not. This means that adaptively, depending on the content of the noise and the content of the image, each frequency will be amplified by a value ranging from zero, when there is a lot of noise, to the inverse filter, when there is no noise. The values in between, it finds the best tradeoff to do a certain degree of the inverse filter. Essentially, the Weiner filter behaves like the inverse filter at low frequencies and like a low-pass filter for high frequencies.
I hope now you understand the main idea of image restoration through inverse filters and Weiner filters. Have a great day! :)