Remove stripes from image using FFT I try to remove from an image all stripes with slope between 110° and 120° (Fig. 1a) and my first idea was to filter my image in the frequency domain.

As far as I remembered, the spectrum of those stripes should occupy a pie segment between 20-30° (i.e. the original slope - 90°), but to be sure I prepared an artificial black-and-white image with similar pattern (Fig. 2a). It seemed my speculations were correct (Fig. 2b).

Now, I tried to create a mask and simply "cut off" part of the spectrum to supress high frequencies associated with 10-120° stripes.

Only after several trials I came across a mask (Fig. 3a) which satisfies my needs to some degree (Fig. 4). However, I can't figure the relation between this empirically-obtained mask and the spectrum.

Could someone give me some advice where are flaws in my code or in my reasoning?


Here's the MATLAB code I've used for filtering:

f = imread('img/crystal-grain_sample.jpg');
figure, imshow(f); title('f');

m = max(size(f));
P = 2^nextpow2(2*m);
PQ = [P, P];

Fp = fft2(f, PQ(1), PQ(2));

Fc = fftshift(Fp);
Fc_abs = abs(Fc);
Fs_log = log(1+Fc_abs);

%figure; imshow(Fc_abs, []); title('Fc (abs)');
%figure; imshow(Fs_log, []); title('Fs (log)');

Hp = im2double(imread('spec-mask.png'));
Gp = Hp .* Fp;
gp = real(ifft2(Gp));
gpc1 = gp(1:size(f,1), 1:size(f,2));
figure; imshow(gpc1, []); title('g');


And here's the original image:
The problem was I've masked the shifted spectrum. After I've used ifftshift on my mask, I obtained the desired effect.



PS. geometrikal - thanks for putting me on the right track!