You are on page 1of 8

% %ideal low pass%%

clear all
clc
a=imread(“C:\sunset.jpg”)
a=double(a);
c=size(a);
N=c(1)
D0=input(‘Enter the cut-off frequency’);
for u=1:1:c(1)
for v=1:1:c(2)
D=((u-N/2))^2+(v-(N/2))^2)^0.5;
If D<D0;
H(u,v)=1;
Else
H(u,v)=0;
end
end
end
vv=fft2(a);
vc=fftshift(vv);
x=vc.*H;
X=abs(iift2(x));

%%Plotting%%
figure(1), imshow(uint8(a))
figure(2), mesh(H)
figure(3), imshow(uint8(X))
figure(4), image(H),colormap(gray)
% %low pass Butterworth filter%%
clear all
clc
a=imread(“C:\sunset.jpg”)
a=double(a);
c=size(a);
n=c(1);
n=input(‘Enter the order of the filter’)
D0=input(‘Enter the cut-off frequency’);
for u=1:1:c(1)
for v=1:1:c(2)
D=((u-N/2))^2+(v-(N/2))^2)^0.5;
H(u,v)=1/(1+(D/D0)^(2*n)));
end
end
vv=fft2(a);
vc=fftshift(vv);
x=vc.*H;
x=abs(iift2(x));

%%Plotting%%
figure(1), imshow(uint8(a))
figure(2), mesh(H)
figure(3), imshow(uint8(X))
figure(4), image(H),colormap(gray)
% %low pass Gaussian filter%%
clear all
clc
a=imread(“C:\sunset.jpg”)
a=double(a);
c=size(a);
N=c(1);
D0=input(‘Enter the cut-off frequency/Standard deviation’);
for u=1:1:c(1)
for v=1:1:c(2)
Dx=((u-N/2))^2+(v-(N/2))^2)^0.5;
D=Dx*Dx
H(u,v)=exp(-D/(2*D0*D0));
end
end
vv=fft2(a);
vc=fftshift(vv);
x=vc.*H;
X=abs(iift2(x));

%%Plotting%%
figure(1), imshow(uint8(a))
figure(2), mesh(H)
figure(3), imshow(uint8(X))
figure(4), image(H),colormap(gray)
% %ideal high pass filter%%
clear all
clc
a=imread(“C:\sunset.jpg”)
a=double(a);
[row col]=size(a);
set=input(‘Enter the value of the cut-off frequency’);
for u=1:1:row
for v=1:1:col
D=((u-(row/2))^2+(v-(col/2))^2)^0.5
If D<set;
H(u,v)=0;
else
H(u,v)=1;
end
end
end
vv=fft2(a);
vc=fftshift(vv);
x=(vc.*H);
X=abs(iift2(x));

%%Plotting%%
figure(1), imshow(uint8(a))
figure(2), mesh(H)
figure(3), imshow(uint8(X))
figure(4), image(H),colormap(gray)
% %High pass Butterworth filter%%
clear all
clc
a=imread(“C:\sunset.jpg”)
a=double(a);
c=size(a);
N=c(1);
N=input(‘Enter the order of the filter’)
D0=input(‘Enter the cut-off frequency’);
for u=1:1:c(1)
for v=1:1:c(2)
D=((u-N/2))^2+(v-(N/2))^2)^0.5;
H(u,v)=1/(1+(D0/D)^(2*n)));
end
end
vv=fft2(a);
vc=fftshift(vv);
x=vc.*H;
x=abs(iift2(x));

%%Plotting%%
figure(1), imshow(uint8(a))
figure(2), mesh(H)
figure(3), imshow(uint8(X))
figure(4), image(H),colormap(gray)
% % High pass Gaussian filter%%
clear all
clc
a=imread(“C:\sunset.jpg”)
a=double(a);
c=size(a);
N=c(1);
D0=input(‘Enter the cut-off frequency/Standard deviation’);
for u=1:1:c(1)
for v=1:1:c(2)
Dx=((u-N/2))^2+(v-(N/2))^2)^0.5;
D=Dx*Dx
H(u,v)=1-exp(-D/(2*D0*D0));
end
end
vv=fft2(a);
vc=fftshift(vv);
x=vc.*H;
X=abs(iift2(x));

%%Plotting%%
figure(1), imshow(uint8(a))
figure(2), mesh(H)
figure(3), imshow(uint8(X))
figure(4), image(H),colormap(gray)
%%2-D Fourier transform using 1-D Fourier transform%%
clear all
clc
a=-0 1 2 1; 1 2 3 2; 2 3 4; 1 2 3 2];
s=size(a);
aa=fft2(a);

for k=0:1:s(1)-1
for n=0:1:s(2)-1
p=exp(-i*2*pi*k*n/s(2));
x=(k+1,n+1)=p;
end
end

for n=1:1:s(2)
d=x*a(n,:).’;
z(:,n)=d;
end

for nl=1:1:s(2)
dl=x*z(nl,:).’;
z1(:,n1)=d1;
end
z1

%%2-D Fourier transform using the 1-D transform(on actual square image)%%

clear all
clc
aa=imread(‘C:\sunset.jpg’);
a=double(aa);
a1=abs(fft2(a));
s=size(a);

for k=0:1:s(1)-1
for n=0:1:s(2)-1
p=exp(-i*2*pi*k*n/s(2));
x(k+1, n+1)=p;
end
end

for n=1:1:s(1)
d=x*a(n,:).’;
z(:,n)=d;
end
for n1=1:1:s(2)
d1=x*z(nl,:),’;
z1(:,nl)=dl;
end

for n1=1:1:s(2)
d1=x*z(nl,:),’;
z1(:,nl)=dl;
end

%%Plotting%%
z=abs(z1) ;
figure(1)
colormap(gray)
imagesc(fftshift(log(1+z)))
figure(2)
colormap(gray)
imagesc(fftshift(log(1+a1)))

You might also like