Hey i want to do simple low-pass filter in frequency domain with cutoff frequency 0,2. I need to create mask in frequency plane. Here is my code but it is not elegant at all. Since i am using normalized frequency i have to use normalize distance is that right? is there a elegant way to do it without so many loops? i have to do it manually without using fspecial function. Thank you!
[m n]=size(im);p=m/2;q=n/2;d0=0.2;for i=1:m for j=1:n distance(i,j)=sqrt(((i-p)^2+(j-q)^2)); endend distance=mat2gray(distance);for i=1:m for j=1:n Hglp(i,j)=(exp(-(distance(i,j))^2/(2*(d0^2)))); endend
Best Answer