File Exchange

image thumbnail

Ideal Low Pass Filter

version 1.0 (1.2 KB) by

Ideal Low Pass Filter using DFT

45 Downloads

Updated

View License

Ideal Low Pass Filter using Discrete Fourier Transform

Comments and Ratings (27)

chanlaisa

Tsai Terry

hewaa mero

when i am using this code and giving input as
f=imread('lena.jpg'); and after running it is giving the following error

??? Input argument "P" is undefined.

Error in ==> idealfilter at 13
H=double(D<=P);

can any body tell me how can i remove dis error...

amitesh kumar

when i am using this code and giving input as
f=imread('lena.jpg'); and after running it is giving the following error

??? Input argument "P" is undefined.

Error in ==> idealfilter at 13
H=double(D<=P);

can any body tell me how can i remove dis error...
 

Ömer KAYA

The thing is that everybody said; this is junk this that this is it...

It is just code... a helpfull one... just download and use...
it says.. imread(X)... what else do you need for to get the code running.... just an input image...

Rest is detail... it works...

Hello,
I'm reinhart..
I still don't know what the meaning of parameter P?
can I request an explanation?
Thank you,

thanks a lot.. could you clarify about the parameter P?

Adam Baker

File exchange could do without this kind of submission. No explanation at all.

Alejandro Stepnik

Hi, I am new to image processing and i need to filter some grayscale images with low and high frequency band filters.
Your code works fine but I still don't quite understand the parameter P. If I had to filter the image so that only frequencies < 6 cycles per degree where displayed on the image when viewed form 80 cm distance, then don't know how to calculate the accurate P value.
Could you give me a hint on this? I would really apreciate it

Thank you very much

AB C

I think, if you wnat to use this to a full color image, you might need some changes...

%Question No:5
%IDEAL LOW-PASS FILTER

function idealfilter(X,P)
f=imread(X);
[M,N,O]=size(f);
F=fft2(double(f));
u=0:(M-1);
v=0:(N-1);
idx=find(u>M/2);
u(idx)=u(idx)-M;
idy=find(v>N/2);
v(idy)=v(idy)-N;
[V,U]=meshgrid(v,u);
D=sqrt(U.^2+V.^2);
H=double(D<=P);
G=F;
for i = 1:O
    G(:,:,i) = H.*F(:,:,i);
end
g=uint8(real(ifft2(double(G))));
imshow(f),figure,imshow(g);
end

yu peter

??

nancy m

this is a load of crap!

senthilkumar subramaniam

can anyone tell me how to implement this file ? It can't work. When i run the file from editor/debug, errors appear.

prom etheus

awful

PT sad

The worst low-pass filter ever. Not ideal at all. That's hard to believe than more than 5000 (hopeless?) people have downloaded it. Examples in the Matlab documentation are by far much better (and not poorly coded). Is FEX finally just a collection of irrelevant poor codes?

Xander Baker

This code has no comments, but it works just spledidly -- it was designed for 2-D Images of a generic length. As a better illustration, try this code for an image with equal height and width.

% Ideal low pass filter
img = X/max(max(X));
P=[10 20 50 100];
% generate a mask to apply over the
% image's fourier transform.
% for square images, we can simplify the
% code to make a mask:
[L,W]=size(img);
for t=1:length(P)
    for i=1:L
        for j=1:L
            dFromCenter = sqrt((i-L/2)^2 + (j-L/2)^2);
            H(i,j)=double(dFromCenter<=P(t));
        end
    end
    % apply the mask over the transform
    F=fftshift(fft2(img)); % fft the image,
                    % bringing the 0
                    % frequencies to
                    % center
    G=fftshift(H.*F); % mask out outer
                    % frequencies and shift
                    % back to image state
    g=real(ifft2(double(G)));
    figure(5);
    subplot(2,2,t);
    imshow(g);
    title(sprintf('ILPF P=%1.f',P(t)));
end

Duane Hanselman

This is just a poorly done homework problem. What does ideal mean? Here is the first three lines of the file:
%Question No:5
%IDEAL LOW-PASS FILTER
function idealfilter(X,P)

Stewart Thomas

This program is horrible. Not a single comment, no explanation of how to use. This is not even ready to be generalized.

h j

S K

This is a perfect example of junk submission- posting some badly written homework assignments. Please remove it all from FEX, there is enough junk already.

2 charles khoo: You marked file that you couldn’t even run as excellent. I wonder what mark do you give to the function that DOES work?

charles khoo

Hallo, can anyone tell me how to implement this file ? It can't work.
When i run the file from editor/debug, errors appear.

Jithin R.G

martin barrera

Thanks a lot.

Deepan chakravarrthy

ARJUN KUMAR

Thanks for helping program

MATLAB Release
MATLAB 7 (R14)
Acknowledgements

Inspired: Ideal Low-Pass Filtering of an Image

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video