111
$\begingroup$

I was just learning about the frequency domain in images.

I can understand the frequency spectrum in case of waves. It denotes what frequencies are present in a wave. If we draw the frequency spectrum of $\cos(2\pi f t)$, we get an impulse signal at $-f$ and $+f$. And we can use corresponding filters to extract particular information.

But what does frequency spectrum means in case of images? When we take the FFT of a image in OpenCV, we get a weird picture. What does this image denote? And what is its application?

I read some books, but they give a lot of mathematical equations rather than the physical implication. So can anyone provide a simple explanation of the frequency domain in images with a simple application of it in image processing?

$\endgroup$
  • 5
    $\begingroup$ The best way to understand what a transform does is to play around with feeding simple inputs to the inverse transform. $\endgroup$ – endolith May 13 '13 at 21:07
  • 1
    $\begingroup$ See also this interesting explanation by Steve Eddins blogs.mathworks.com/steve/2009/12/04/… $\endgroup$ – Alessandro Jacopson Nov 8 '15 at 13:19
  • $\begingroup$ @endolith Yeah! you need some knowledge on domain beforehand to fully understand what is happening and why it is happening.. $\endgroup$ – SIslam Apr 9 '16 at 9:29
  • $\begingroup$ dear the frequency domain of the image represent the power intensity in watt with respect to the certain frequency in hertiz such as (dc component, low frequency and high frequency) $\endgroup$ – mntaser Feb 27 '17 at 22:23
93
$\begingroup$

But what does frequency spectrum means in case of images?

The "mathematical equations" are important, so don't skip them entirely. But the 2d FFT has an intuitive interpretation, too. For illustration, I've calculated the inverse FFT of a few sample images:

enter image description here

As you can see, only one pixel is set in the frequency domain. The result in the image domain (I've only displayed the real part) is a "rotated cosine pattern" (the imaginary part would be the corresponding sine).

If I set a different pixel in the frequency domain (at the left border):

enter image description here

I get a different 2d frequency pattern.

If I set more than one pixel in the frequency domain:

enter image description here

you get the sum of two cosines.

So like a 1d wave, that can be represented as a sum of sines and cosines, any 2d image can be represented (loosely speaking) as a sum of "rotated sines and cosines", as shown above.

when we take fft of a image in opencv, we get weird picture. What does this image denote?

It denotes the amplitudes and frequencies of the sines/cosines that, when added up, will give you the original image.

And what is its application?

There are really too many to name them all. Correlation and convolution can be calculated very efficiently using an FFT, but that's more of an optimization, you don't "look" at the FFT result for that. It's used for image compression, because the high frequency components are usually just noise.

$\endgroup$
  • 3
    $\begingroup$ can you specify which is highfrequency part and which is low frequency part in frequency domain image? $\endgroup$ – Abid Rahman K Mar 6 '12 at 16:40
  • 4
    $\begingroup$ @arkiaz: In the images I've shown, the highest frequency is in the center of the image, lowest frequency (i.e. the mean of the input image) is top left pixel in the FFT result. That's what most FFT implementations give you. If you display the FFT result, it's common to move the lowest frequency to the center of the displayed image. $\endgroup$ – Niki Estner Mar 6 '12 at 17:50
  • 1
    $\begingroup$ @Mohammad: I've used Mathematica's InverseFourier function. Doesn't octave/matlab's ifft2 do the same? $\endgroup$ – Niki Estner Mar 7 '12 at 7:21
  • 1
    $\begingroup$ @JimClay For color images, I would actually recommend using the YUV domain. Y = absolute intensity and UV = color. Even for color images, most of the information you're interested in is in the intensity portion of the image. You use all the same mathematical tools, just remember to transform back. $\endgroup$ – Atav32 Jun 22 '12 at 18:34
  • 4
    $\begingroup$ These would be great as animations, like move the point around and show how the waves change width and angle $\endgroup$ – endolith May 9 '14 at 20:11
29
$\begingroup$

I think this was put very well in the well known "DSP guide" (chapter 24, section 5):

Fourier analysis is used in image processing in much the same way as with one-dimensional signals. However, images do not have their information encoded in the frequency domain, making the techniques much less useful. For example, when the Fourier transform is taken of an audio signal, the confusing time domain waveform is converted into an easy to understand frequency spectrum.

In comparison, taking the Fourier transform of an image converts the straightforward information in the spatial domain into a scrambled form in the frequency domain. In short, don't expect the Fourier transform to help you understand the information encoded in images.

So there is, of course, some structure and meaning behind the seemingly random pattern obtained by taking the DFT of a typical image (such as the example below), but it is not in a form that the human brain is prepared to understand intuitively, at least regarding visual perception.

Imgur

Here is another interesting and quite readable exposition of what is contained in a Fourier transform of an image, and how it can be interpreted. It has a series of images that make it quite clear what the correspondence is between the Fourier-transformed and the original image.

edit: take also a look at this page, which demonstrates —near the end— how most of the perceptually important information of an image is stored in the phase (angle) component of the frequency representation.

edit 2: another example of the meaning of phase and magnitude in the Fourier representation: "Section 3.4.1, Importance of phase and magnitude" of TU Delft's textbook "Fundamentals of Image Processing" demonstrates this quite clearly:

Imgur

$\endgroup$
  • $\begingroup$ Hey! I tried following the second link in your question ("another interesting and quite readable exposition...") but the link is not working. I also tried the link provided in the comments, but does not work. Could you find and edit in a working link please? $\endgroup$ – penelope Jan 14 '14 at 10:36
  • $\begingroup$ @penelope you're the second person to notice problems with the link (see my previous comment). The page seems to be unstable, indeed. As I said previously, I'll replace the link with the Web Archive version. Thanks for pointing this out! $\endgroup$ – waldyrious Jan 16 '14 at 3:47
  • 1
    $\begingroup$ Actually, the examples and explanations at the (finally working) link are great :) $\endgroup$ – penelope Jan 16 '14 at 8:58
12
$\begingroup$

The wave $f(t)=cos (ωt)$ is a one-dimensional wave; it depends only on $t$. The wave $f(x,y)=cos(ωx+ψy)$ is a two-dimensional wave. It depends on $x$ and $y$. As you see, you have two frequencies, in either direction.

Therefore, the fourier transform (FFT) of $cos(ωx+ψy)$ will give you $ω,ψ$, just like the FFT of $cos(ωx)$ gives you $ω$. And if your input is a function summing 2D cosines, then your 2D FFT will be the sum of the frequencies of those cosines - again a direct analog of the 1D FFT.

$\endgroup$
10
$\begingroup$

It may be worth noting that Fourier Analysis is a special case of a concept called orthogonal functions. The basic idea is that you break down a complicated signal into a linear superposition of simpler "basis" functions. You can do your processing or analysis on the basis functions and then sum the results for the basis functions to get the result for the original signal.

In order for this to work there are certain mathematical requirement for the basis functions, i.e. they ideally form an orthonormal base. In case of the Fourier Transform the basis functions are complex exponentials. However, there are many other functions that can be used for that as well.

$\endgroup$
  • $\begingroup$ Thats true. What other types of basis functions are there? I am thinking daubechies wavelets, but are there other ones too? What would differentiate them? $\endgroup$ – Spacey Mar 8 '12 at 23:39
  • $\begingroup$ Probably the best known are the polynomials; the representation of a function as a set of polynomials is known as its Taylor serie. This serie is easily calculated from the function derivatives. $\endgroup$ – MSalters Mar 9 '12 at 9:22
  • 2
    $\begingroup$ One way to find basis functions is applying Principal Components Analysis. The resulting 'eigen-images' often have a more human-intuitive appearance than sin/cos functions. For an example, see Eigenfaces. The frequency domain is still relevant for perception (our eyes/brains have edge-detectors that are sensitive to frequency, particularly when motion is involved); the basis functions are just not very meaningful as images. $\endgroup$ – Dan Bryant May 16 '13 at 13:40
  • $\begingroup$ PCA is a nice basis computation technique that's widely understood, but there are many others that make different assumptions about how the data was generated; Independent Component Analysis (ICA) is one popular example. A bit further afield, there are algorithms for generic basis function learning using sparse coding (e.g. J Mairal et al., "Online dictionary learning for sparse coding," ICML 2009), and then the "feature learning" approaches developed by the deep nets folks. $\endgroup$ – lmjohns3 Aug 22 '13 at 22:17
  • 1
    $\begingroup$ Why do the functions have to be orthogonal? $\endgroup$ – quantum231 Sep 27 '14 at 20:39
8
$\begingroup$

In images increasing frequency is associated with more abrupt transitions in brightness or color. Furthermore, noise is usually embedded in the high end of the spectrum, so low-pass filtering can be used for noise reduction.

$\endgroup$
  • 1
    $\begingroup$ so you mean abrupt transitions are sometimes regarded as noise? $\endgroup$ – Abid Rahman K Mar 7 '12 at 14:53
  • 1
    $\begingroup$ Yes, sometimes. Common examples include mosquito noise (ringing around edges), JPEG block noise at the edges of the macroblocks and, of course, grain. Consider an image of a simple gradient. Adding grain to this image increases its high-frequency content by introducing minute transitions throughout the image. $\endgroup$ – Emre Mar 8 '12 at 1:12
5
$\begingroup$

in this context a very nice demo: http://bigwww.epfl.ch/demo/basisfft/index.html

$\endgroup$
  • $\begingroup$ Not (really) an answer and should be a comment. $\endgroup$ – EdParadox Aug 5 at 15:15

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.