Hello all
Sorry for basic question, my understanding of fourier transforms is apparently quite limited.
I've got an image with some spatial oscillations hidden in it, and I'm trying to use a 2D fourier transform to find components of their wavevectors (in both the x and y directions).
The image is 80 pixels high and 100 wide, and for now I'm just assuming that 1 pixel = 1 unit length, so the spatial sampling frequency is 1.
I've done a 2D fourier transform of the image, but I can't figure out how to work out the spatial frequencies of the oscillations from the resulting plot.
The code below is a minimal working example, which produces the image and the 2D FT.
vidHeight = 80;
vidWidth = 100;
k1 = 0.1;
k2 = 0.6;
k3 = -0.8;
k4 = 0.7;
generatedOscillation = zeros(vidHeight, vidWidth);
for x = 1:vidWidth
for y = 1:vidHeight
generatedOscillation(y,x) = generatedOscillation(y,x) + 1.2;
generatedOscillation(y,x) = generatedOscillation(y,x) + sin(k1*x + k2*y);
generatedOscillation(y,x) = generatedOscillation(y,x) + sin(k3*x + k4*y);
end
end
imagesc(generatedOscillation)
NFFTY = 2^nextpow2(vidHeight);
NFFTX = 2^nextpow2(vidWidth);
av = sum(generatedOscillation(:)) / length(generatedOscillation(:));
generatedOscillation = generatedOscillation - av;
samplingFreq = 1;
spatialFreqsX = samplingFreq/2*linspace(0,1,NFFTX/2+1);
spatialFreqsY = samplingFreq/2*linspace(0,1,NFFTY/2+1);
spectrum2D = fft2(generatedOscillation, NFFTY,NFFTX);
spectrum2D = fftshift(spectrum2D);
imagesc(abs(spectrum2D))
I can see four peaks on the 2D FT, but I can't figure out how to translate these peaks into the wavevectors I'm looking for (ie find k1, k2, k3 and k4). I'm also confused about what the x and y axis of the 2D FT mean, and their units. Comparing this with the 1D FT, I would guess that they have units of spatial cycles per unit length (or in this case, spatial cycles per pixel, since I've assumed 1 pixel = 1 unit length).
Any help would be most appreciated.
Many thanks
Dave