I'm a Matlab Newb. I'm currently experimenting with Fourier Transformation and trying to implement a frequency filter (deleting all frequencies but those between k_min and k_max).
In order to realize that, I'm deleting the respective pixels in the Fourier transformed image. I'm using the following code:
% Example values
kmin = 0;
kmax = 300;
for i = 1:w
for j = 1:h
if norm([w/2, h/2] - [i,j]) < kmin || norm([w/2, h/2] - [i,j]) > kmax
Fs(j,i) = 0.0;
end
end
end
My image is about 1000x600. Fs is therefore a 1000x600 array of COMPLEX NUMBERS. Now my problem: Why is this so slow? If I set very few pixels to zero (e.g. kmin = 10, kmax = infinite) then the code runs quickly but if I have to set almost all pixels to 0.0 (e.g. kmin = 0, kmax = 10) it takes an incredible amount of time to complete.
All I do is set some array entries to zero (worst case less than 1,000,000 entries, maybe factor two because they are complex numbers). Why does this take up to minutes? :)