Natural Images can be denoised using what we know about natural scene statistics. Namely, natural images have a 1/f2 power spectrum. Using this information as our prior, we can use bayesian inference in order to denoise an image which has been corrupted by gaussian noise. Using the same framework, we can also fill in an image where 99% of the true pixel values are missing. Finally, we compare this simple bayesian inference approach to modern AI methods for denoising and filling in.
Introduction
This blog will introduce and demonstrate how to use natural image statistics in order to denoise an image. The first part will explore the 1/f2 power spectrum of natural images. The second part will discuss using bayesian inference in order to denoise an image. The third part will implement Simoncelli et al.’s “NOISE REMOVAL VIA BAYESIAN WAVELET CORING” in order to do denoising. The fourth part will discuss using gradient descent with langevin sampling in order to denoise an image. The fifth part will demonstrate filling in an image where a large percentage of pixels are missing. The sixth and final part will compare these methods to standard deep learning techniques for denoising and filling in.
What do we know about natural images? (1/f2 power spectrum)
Click here to expand Fourier transform explanation Click here to hide Fourier transform explanation
Fourier's theorem was first proposed in 1807 but not published until 1822 due to the skepticism of many leading mathematicians who did not think it could be true. Today, it provides the theoretical foundation for the Fourier transform which is one of the most widely used tools in all of science and engineering, from radio astronomy and signal processing to neuroscience and modern machine learning. For example, it is used for:
- analyzing the frequency content of natural signals such as sound waveforms.
- detecting rhythmic activity in brain signals - e.g., EEG, LFP and spike train recordings.
- even when there is no periodic structure - characterizing the length scale of correlations over time or space, since the power spectrum is the Fourier transform of the auto-correlation function.
- identifying the input-output relationship of linear systems.
Here we will experiment with Fourier decompositions of simple 1D waveforms and 2D images, to gain some intuition about what the Fourier transform tells you about a signal, and how it can be used to manipulate images to demonstrate perceptual phenomena.
Fourier's theorem states that any continuous function can be described as a weighted sum of sine and cosine waveforms at different frequencies:
where and are the weights of the sine and cosine components, respectively, and is the frequency in radians per unit of (space or time). Alternatively if we define
we may rewrite the equation equivalently as
where now is described simply as a sum of cosine waves, each with amplitude and phase-shifted by . We refer to as the amplitude spectrum and as the phase spectrum of .
To gain some intuition for the power and generality of the Fourier theorem, let us first decompose a simple step-function this way. The function is
You are given as a discretely sampled function. In the image below you can see that even though looks nothing like a sinusoid, we can nevertheless describe it perfectly by adding sinusoids of different frequencies together, as long as they are given the correct amplitudes and phases.
The direct method of computing the amplitude and phase spectrum of a function is the Fourier transform! Looking back at the Fourier theorem, we can compute the Fourier coefficients and from the discretely sampled function , as follows:
where . Intuitively, we can think of these equations as measuring the similarity between and the sine function, and the similarity between and the cosine function, for each frequency .
Formally, we can show this gives us exactly the Fourier coefficients and in the Fourier theorem by plugging the expression for into these equations and utilizing the orthogonality of sines and cosines of different frequencies, or sine and cosine of the same frequency.
Once you have computed and , the amplitude spectrum and phase spectrum can be computed via and .
A 2D image may also be described in terms of a Fourier decomposition as follows:
where and correspond to frequencies in the and dimensions of the image, respectively. Each sinewave component now corresponds to a 2D grating of a specific spatial-frequency and orientation. You can use the demo below to build up an image from its Fourier components, one component at a time.
Note how the amplitudes fall off with frequency. At some point, the amplitudes are so small that the gratings are not even visible, yet they are clearly needed to reconstruct. This seems paradoxical - gratings which are invisible in isolation nevertheless create structure when combined. The squared amplitudes have a 1/f2 [1] fall off relationship, which is shown in the dashed line. This phenomenon of 1/f power spectra is not unique to natural images — it occurs all throughout nature such as in music [2].