Code covered by the BSD License  

Highlights from
Ideal Low Pass Filter

2.85

2.9 | 20 ratings Rate this file 140 Downloads (last 30 days) File Size: 1.2 KB File ID: #13586

Ideal Low Pass Filter

by Madhu S. Nair

 

09 Jan 2007 (Updated 12 Jan 2007)

Ideal Low Pass Filter using DFT

| Watch this File

File Information
Description

Ideal Low Pass Filter using Discrete Fourier Transform

Required Products Image Processing Toolbox
MATLAB release MATLAB 7 (R14)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (24)
28 Jan 2007 ARJUN KUMAR

Thanks for helping program

09 Feb 2007 Deepan chakravarrthy  
19 Mar 2007 martin barrera

Thanks a lot.

27 Mar 2007 Jithin R.G  
24 May 2007 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.

24 Sep 2007 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?

06 Oct 2007 h j  
11 Nov 2007 Stewart Thomas

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

13 Nov 2007 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)

10 Mar 2008 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

11 Mar 2008 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?

31 Mar 2008 prom etheus

awful

24 Apr 2008 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.

10 May 2008 nancy m

this is a load of crap!

02 Jun 2008 yu peter

??

07 Jul 2008 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

30 Sep 2008 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

23 Oct 2008 Adam Baker

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

07 Apr 2009 Ricardo Barrios  
02 Nov 2009 steppenwolf Nayak

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

10 Mar 2010 velocity speed

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

17 Nov 2010 Ö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...

30 Jan 2011 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...
 

07 Apr 2011 JOSE RAMON SIERRA BLASCO  
Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
filtering Madhu S. Nair 22 Oct 2008 08:55:43
ideal low pass filter Madhu S. Nair 22 Oct 2008 08:55:43
ideal low pass filter heba saad 30 Dec 2008 15:13:32
ideal low pass filter Johannes 11 Sep 2009 04:39:47
ideal low pass filter Zoltan 18 Sep 2009 04:49:57
filtering Zoltan 18 Sep 2009 04:50:03
ideal low pass filter Ruben Crisan 04 Jan 2010 07:33:10
filtering Sebastian Trostmann 29 Jan 2010 08:31:05
ideal low pass filter Carmen 13 May 2010 09:56:25
filtering kuoping 29 Jun 2010 07:11:27
ideal low pass filter hassan dao 22 Dec 2010 10:18:46
filtering JOSE RAMON SIERRA BLASCO 07 Apr 2011 05:51:18
ideal low pass filter Jeroen 23 Jun 2011 13:53:29
filtering nadav 28 Jul 2011 13:59:55
ideal low pass filter Dennis 22 Aug 2011 11:37:00
filtering Dennis 22 Aug 2011 11:37:10
ideal low pass filter Himkar 21 Sep 2011 07:06:15
ideal low pass filter Aji D 27 Sep 2011 13:37:26
ideal low pass filter Dimitris 02 Nov 2011 15:00:43
filtering Pham Truong 17 Nov 2011 15:33:54

Contact us at files@mathworks.com