Low pass filter for image

I want to create a lowpass filter (circle!) for an 110 x 160 pixel image.
The cut-off frequency should be 0.13/pixel.
What I tried so far:
bricks = im2double(imread("bricks.jpg"));
y1 = fft2(bricks);
[N, M] = size(bricks);
u = -1/2:1/M:1/2-1/M;
v = -1/2:1/N:1/2-1/N;
[U, V] = meshgrid(u, v);
d = U.*U/(0.13*0.13) + V.*V/(0.13*0.13);
mask = d <= 1;
yt1 = fftshift(y1);
yt1 = yt1.*mask;
low_filtered_image = ifft2(ifftshift(yt1), 'symmetric');
The spectrum of my filter and the filtered spectrum look like this:
That gives me the following result for my lowpass filtered image:
But I am not sure if this is correct.

Risposte (1)

Image Analyst
Image Analyst il 24 Giu 2023

1 voto

Use fft2, then zero out anything beyond 0.13. I'll leave it to you to figure out what index that is in the spectral image.
This looks like a homework problem. If you have any questions ask your instructor or read the link below to get started:
Obviously we can't give you the full solution because you're not allowed to turn in our code as your own.

4 Commenti

Dominik Deml
Dominik Deml il 24 Giu 2023
But the return value of fft2 is not the frequency. So how can I compare the return value to a frequency?
Image Analyst
Image Analyst il 24 Giu 2023
The return value of fft2 is the frequency image. Read up on it.
Dominik Deml
Dominik Deml il 25 Giu 2023
Modificato: Dominik Deml il 25 Giu 2023
I know that this is the frequency image. Anyway, I found this post https://stackoverflow.com/questions/64036198/matlab-how-to-apply-low-pass-and-high-pass-filters-using-fft2-and-fftshift . But this does not solve my problem because 0.13 is too low.
Image Analyst
Image Analyst il 25 Giu 2023
Then use a higher value so that less of the spectral image is erased. See attached demos.

Accedi per commentare.

Richiesto:

il 24 Giu 2023

Commentato:

il 25 Giu 2023

Community Treasure Hunt

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

Start Hunting!

Translated by