image processing ideal LPF
4 views (last 30 days)
Show older comments
I made ideal LPF, but dont know it works well
Plz give me advice
close all;
I = rgb2gray(imread('testa.png'));
M = 512;
I = imresize(I, [M, M]);
[m, n] = size(I);
Ip = uint8(zeros(2*m, 2*n));
Ip(1:m,1:n) = double(I);
F = fft2(Ip);
D0 = round(M/10);
u = 0:2*M-1;
v = 0:2*M-1;
[u, v] = meshgrid(u,v);
D = sqrt( (u-((2*M+1)/2)).^2 + (v-((2*M+1)/2)).^2);
H = double(D <= D0);
G = H.*F;
g = ifft2(G);
subplot(2, 2, 1), imshow(I, []), title('Original Image');
subplot(2, 2, 2), imshow(log(1 + abs(fftshift(F))), []), title('Fourier Transform');
subplot(2, 2, 3), imshow(log(1 + abs((H))), []), title('Low-pass Filter');
subplot(2, 2, 4), imshow(real(g), []), title('Filtered Image');
0 Comments
Answers (1)
Image Analyst
on 23 Nov 2023
There is no ideal LPF in general. Maybe there is for your particular image though depending on the high frequency noise in your image. To see how well your script/algorithm works, click the green run triangle. I'm attaching some of my demos for you to compare yours to.
Here's what yours does:
close all;
I = rgb2gray(imread('peppers.png'));
M = 512;
I = imresize(I, [M, M]);
[m, n] = size(I);
Ip = uint8(zeros(2*m, 2*n));
Ip(1:m,1:n) = double(I);
F = fft2(Ip);
D0 = round(M/10);
u = 0:2*M-1;
v = 0:2*M-1;
[u, v] = meshgrid(u,v);
D = sqrt( (u-((2*M+1)/2)).^2 + (v-((2*M+1)/2)).^2);
H = double(D <= D0);
G = H.*F;
g = ifft2(G);
subplot(2, 2, 1), imshow(I, []), title('Original Image');
subplot(2, 2, 2), imshow(log(1 + abs(fftshift(F))), []), title('Fourier Transform');
subplot(2, 2, 3), imshow(log(1 + abs((H))), []), title('Low-pass Filter');
subplot(2, 2, 4), imshow(real(g), []), title('Filtered Image');
0 Comments
See Also
Categories
Find more on Read, Write, and Modify Image in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!