This is my testing image, it is taken from the paper Image Restoration for Linear Local Motion-Blur Based on Cepstrum:

enter image description here

I tried to transform it into its real cepstrum domain with this simple MATLAB code:


But my result is very weird: The maximum is not at the center of image, they are at the 4 corners. And here is the zoomed-in picture with the maximum at the left top corner:

enter image description here

But the result in this paper is like this:

enter image description here

The maximum is actually at the center!!

As I didn't do any fftshift , I don't think I need to do any ifftshift.

  • This makes me so confused. Is there something wrong with my code? or my understanding about 2D real cepstrum with DFT?

UPDATE 1: Why do I think that fftshift or ifftshift is not needed here.

For a length-$N$ sequence $x[n]$, you do an $N$-point DFT. You will get another length-$N$ sequence $X[n]$. The first element of the resulting sequence is corresponded to the zero frequency. Then we do fftshift to the resulting length-$N$ sequence, and we get a third length-$N$ sequence $X'[n]$, because we want to make the center (may not be at the center if $N$ is even) of the element in $X'[n]$ corresponded to the zero frequency.

  • The question is how can you get the original $x[n]$ with IDFT?

$\textrm{IDFT}(X[n])$ is right. $\textrm{IDFT}(X'[n])$ is wrong.

Check this MATLAB code:

% the original sequence
% this will give you the original sequence
% but this won't
% anyway, the amplitude is the same.

The case would be the same for images and fft2 & ifft2. i.e.this will get you the original img:


And if the cepstrum is defined as

$$C=\mathcal F^{-1}\left\{\ln\left(\lvert \mathcal F\left\{I(x,y)\right\}\rvert\right)\right\}$$

Where $I$ = img. This is something like transforming from Fourier domain back to the spatial domain.

UPDATE 2: I found where I am wrong..

When the papers are saying

The Cepstrum (Calculated with FT) has the maximum at the center

I misunderstood it as

The Cepstrum calculated with DFT & IDFT has the maximum at the center

If the Cepstrum above is really calculated with Fourier transform, the Cepstrum will be with the maximum at the origin. That means if I calculate this with DFT & IDFT,the maximum should be at the corners. The same as FT vs DFT, I have assumed the Cepstrum calculated with DFT should have its maximums at the center. That's where I am wrong.


1 Answer 1


If you have image in the spatial domain, in order to calculate its DFT transform you should use fft.
Once you have its DFT in order to get back to the spatial domain use the function ifft.

Either way, the DFT transform gives you the data in the [0, 2pi] axis.
Use fftshift to move it into the [-pi, pi] domain as seen in the paper.

Good Luck.


This code worked for me:

mInputImage = imread('3.png');
mInputImage = double(mInputImage) / 255;
mInputImage = mean(mInputImage, 3);

mImageDft = (fft2(mInputImage));

mImageDft = log(1 + abs(mImageDft));

mImageCepstrum = abs(fftshift(ifft2(mImageDft)));

mImageCepstrum = mImageCepstrum / max(mImageCepstrum(:));



  • $\begingroup$ thank you @Drazick. But I have used both fft2 and ifft2 in my codes. The Real cepstrum is defined as $cepstrum=F^{-1}(log|F(I(x,y))|)$ . So I think there's no need to use ifftshift or fftshift. $\endgroup$ Jul 19, 2014 at 7:38
  • $\begingroup$ @alexyangfox, Have a look at my code. It worked for me (Namely, the function maximum was centered). $\endgroup$
    – Royi
    Jul 19, 2014 at 7:52
  • $\begingroup$ Thank you very much.. It really works..But I am wondering whether the maximum should really be at the center. $\endgroup$ Jul 19, 2014 at 14:47
  • $\begingroup$ Thank you very much again . Yes,You are right.When the papers are saying The Cepstrum (Calculated with FT) has the maximum at the center,I misunderstood it with The Cepstrum calculated with DFT & IDFT has the maximum at the center $\endgroup$ Jul 21, 2014 at 9:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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