MATLAB: Image classification using fourier transform

fftimage processingImage Processing Toolbox

I can get the Fourier transform frequency domain using the MATLAB fft2() code, but I want to get the highest spectrum magnitudes and the DC. What should I do?
The purpose is to :
  1. Get the frequency domain representation F(U,v) of g(x,y) using Fourier Transform.
  2. What is the DC value of (u,v)?
  3. Select the three highest spectrum magnitudes as the image’s signature vector.
  4. Obtain the signature vector for each image in each class.
  5. Use nearest neighbor to assign f(u,v) to its closest class.
I found this code that gets the magnitude:
% Perform 2D FFTs
fftA = fft2(double(imageA));
% Display magnitude and phase of 2D FFTs
imshow(abs(fftshift(fftA)),[24 100000]);
colormap gray
title('Image A FFT2 Magnitude')

Best Answer

If you want the max, call max():
fftMagnitude = abs(fftshift(fftA));
maxValue = max(fftMagnitude(:));
Doing that will not find two images that match though. Unless they match exactly, i.e. it's the very same image.
For what it's worth, I've attached assorted fft demo programs, though they aren't doing image matching like you want. You might use immse() or psnr() or something like that if you want to find matching images. Though that won't do CBIR if that's what you're after.