# Comparison between 2 images in Frequency domain

As you can see there are 2 images from the Tom and Jerry cartoon program.

In the 1st image both Tom and Jerry are present. But in the 2nd one,only Tom is present.Now,we can clearly see this difference in spatial domain. But i want to compare these images in Frequency domain.

• So can anybody explain how do we compare these 2 images and find out the missing part from the 2nd image i.e. image of Jerry using Fourier transform ?

• Also,is it possible to find out location of Jerry in the image using any frequency transform method? If yes can you explain how?

• Transform 1st and 2nd image into frequency domain and subtract second from the first. the result should be the difference... – Steffen May 27 '15 at 7:30
• @Steffen how could you subtract 2 frequency spectrums? Can you explain it with matlab or opencv code in the answer box? – pandu May 27 '15 at 7:57
• No you can't , you can find some different freequency value. But it does not represent the position. – gmotree Jul 26 '15 at 10:49
• How about trying wavelet? It can be both localized and frequency domain. – aghd Oct 18 '17 at 14:14

1st question: there are some simple steps to change the spatial domain to freq domain, exp adding some zero to avoid ISI, you can read the procedure from a source book, you can use fft2 command in matlab

2nd question: Surely you can not see the differences in freq domain as clear as spatial domain, because to determine the value of one pixel in freq domain all the pixels in the spatial domain will be effective

Because the Fourier Transform is a linear operation, you can add and subtract images either in the spatial domain or in the frequency domain.

If you would like to isolate Jerry in the first image, perform the following steps:

1. Take the Fourier transform of each image.
2. Subtract the Fourier transform of the second image from the Fourier transform of the first image.
3. Take the inverse Fourier transform of the result from Step 2. The result may be complex valued, so display the magnitude. This should show an image of only Jerry.

Fourier Transom of these two surely would be different, but remember Fourier gives a global representation(features) of the images and you need local features to compare those, it is like that you want to compare similarity of two whole images only through comparing their histograms. However, I thing the better approach is to segment the image into smaller blocks and take fourier of those block and compare that. Now, you can both tell which blocks are different and their correspondent location.