image classification using fourier transform
12 次查看(过去 30 天)
显示 更早的评论
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 :
- Get the frequency domain representation F(U,v) of g(x,y) using Fourier Transform.
- What is the DC value of (u,v)?
- Select the three highest spectrum magnitudes as the image’s signature vector.
- Obtain the signature vector for each image in each class.
- 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
figure
imshow(abs(fftshift(fftA)),[24 100000]);
colormap gray
title('Image A FFT2 Magnitude')
0 个评论
采纳的回答
Image Analyst
2016-12-10
编辑:Image Analyst
2016-12-10
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.
15 个评论
Sam Alex
2017-12-9
Hello Raymon, i have an assignment similar to your's, and i cant get the nearest neighbor to assign to its closest class. Could you tell me how to implement it. I would be too much thankful if you could send me your assignment to reference from it the steps of implementation to my email samalexcs1993@gmail.com. Thanks in Advance,
seif amr
2017-12-9
i have the same assignment can you send your assignment to take it as a refrence via e mail seif133649@bue.edu.eg thanks
更多回答(3 个)
Sam Alex
2017-12-9
Hello Raymon, i have an assignment similar to your's, and i cant get the nearest neighbor to assign to its closest class. Could you tell me how to implement it. I would be too much thankful if you could send me your assignment to reference from it the steps of implementation to my email samalexcs1993@gmail.com. Thanks in Advance,
0 个评论
Image Analyst
2017-12-10
The DC value is the value at element (1,1). Get this BEFORE you call fftshift, because fftshift will move the DC location to the center of the image.
To get the "three highest spectrum magnitudes" simply sort and pick off the first 3:
fftMagnitude = abs(fftA);
sortedMags = sort(fftMagnitude(:), 'descend');
threeHighest = sortedMags(1:3);
Note, fftMagnitude(:) turns the 2-D array into a column vector. Also note that in most "normal" signals, the 3 highest signals will be the DC signal and the to elements immediately on either side of the DC element. For them not to be there, you'd need to have some kind of periodic signal in the spatial domain that would give really big spikes in the Fourier (spectral) domain. If the signal is not periodic, like just some general snapshot image you snapped, then it will be highest at DC and fall away sharply as you move away from DC.
0 个评论
Greg Heath
2017-12-10
I learned (decades ago !!!), that explictly removing the mean value before using the FFT eliminates a multitude of problems when trying to use and/or understand the transform.
Reason? The fft of the mean value contains sidelobes that contaminate the spectrum at nonzero frequencies.
Bottom line:
ALWAYS REMOVE THE DC LEVEL BEFORE TRANSFORMING!!!
Hope this helps
Thank you for formally accepting my answer
Greg
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
