Sampling frequency for image

6 visualizaciones (últimos 30 días)
Dominik Deml
Dominik Deml el 24 de Jun. de 2023
Respondida: Image Analyst el 24 de Jun. de 2023
I have an 30 x 30 pixel image that looks like this:
The spatial frequency is 0.1 (1/pixel)
The code to produce this image:
x = 0:1:30;
y = 0:1:30;
[X, Y] = meshgrid(x, y);
fx = 0.1; % spatial frequency [1/Pixel]
p = cos(2*pi*(fx*X + 0*Y)) + 1;
figure;
imshow(p);
colormap('gray');
Now I want to do the fft of the first row of my image:
fs = 1; % sampling frequency
% compute FFT coefficients, norm with the length of the signal
FFTtmp = fft(p(1, :))/length(p(1, :));
% discard redundant coeffcients (n could be odd!)
n = length(p(1, :))/2;
spectrum_signal = FFTtmp(1:floor(n)+1);
% correct values other than DC and fs/2
spectrum_signal(2:end-1) = spectrum_signal(2:end-1)*2;
% create frequency vector (frequency step is fs/length(signal) )
f=(0:floor(n))/n * fs/2;
stem(f, abs(spectrum_signal));
The amplitude spectrum looks like this:
But this is not the result I expected.
I expected only 2 frequencies to be there, 0 and 0.1 (1/Pixel).
So my question is, which sampling frequency do I have to choose?

Respuesta aceptada

Image Analyst
Image Analyst el 24 de Jun. de 2023
Why do you expect only two spatial frequencies. You know that you don't have an infinite cosine wave, right? You know that it is truncated by a rectangular window, right? And you know that multiplication of a spatial signal by a rect function will have the effect of convolution of the cosine spectrum with the spectrum of the rect function, which is a sinc function, right? The convolution will give power at frequencies other than the two corresponding to an infinitely long cosine function. So, no, there will not be just two frequencies.

Más respuestas (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by