1. IDEAL LPF:
clc;
close
all;
clear
all;
a=imread('circuit.tif'); % reading an image X
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(ifft2(x));
figure;
imshow(uint8(a));
title('original
image'),
figure;
imshow(uint8(X));
title('practical
by shruti naik');
figure;
mesh(H);
figure;
imagesc(H),colormap(gray);
2. BUTTERWORTH LPF:
img=im2double(imread('circuit.tif'));
figure(1)
imshow(img)
title('ORIGINAL IMAGE');
[M
N] = size(img); % Saving the the rows of image in M and
columns in N
filter=zeros(M,N);
f_transform=fft2(img); %Fourier transformed of an image
f_shift=fftshift(f_transform);
d0=100;
%10 %210 %Cutoff Frequency
n=2; %Order
of butterworth filter
for i=1:M
for j=1:N
distance=(i-M/2)^2 + (j-N/2)^2; %distance between pt.(m,n)
low_filter(i,j)= ( 1 +
(distance/d0)^(2*n))^(-1);
%butterworthlpf formula
end
end
filter_apply=f_shift.*low_filter;
image_orignal=ifftshift(filter_apply);
image_filter_apply=abs(ifft2(image_orignal));
figure(2)
imshow(image_filter_apply,[])
title('practical performed by shruti');
figure(3)
mesh(low_filter), figure(4)
imagesc(low_filter),colormap(gray);
3. GAUSSIAN LPF:
a=im2double(imread('circuit.tif'));
figure(1)
imshow(a)
title('original image')
[m
n]=size(a); % Saving the the rows of image in M and
columns in N
f_transform=fft2(a);
f_shift=fftshift(f_transform);
%Fourier
transformed of an image
p=m/2;
q=n/2;
d0=25;
%Cutoff Frequency and the sigma value
for i=1:m
for j=1:n
distance=sqrt((i-p)^2+(j-q)^2);
low_filter(i,j)=exp(-(distance)^2/(2*(d0^2)));
end
end
filter_apply=f_shift.*low_filter;
image_orignal=ifftshift(filter_apply);
image_filter_apply=abs(ifft2(image_orignal));
figure(2)
imshow(image_filter_apply,[])
title('practical performed by shruti')
figure(3)
mesh(low_filter)
figure(4)
imagesc(low_filter),colormap(gray);
4. IDEAL HPF:
clc;
a=imread('circuit.tif');
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(ifft2(x));
%Plotting%
figure(1)
imshow(uint8(a));
figure(2)
imshow(uint8(X));
figure(3)
imagesc(H),colormap(gray);
figure(4)
mesh(H);
5. BUTTERWORTH HPF:
img=im2double(imread('circuit.tif'));
figure(1)
imshow(img)
title('ORIGINAL IMAGE');
[M
N] = size(img);
filter=zeros(M,N);
f_transform=fft2(img);
f_shift=fftshift(f_transform);
d0=150; %Cutoff
Frequency
n=2; %Order
of butterworth filter
for i=1:M
for j=1:N
distance=(i-M/2)^2 + (j-N/2)^2;
hf(i,j)= ( 1 +
(d0/distance)^(2*n))^(-1);
end
end
filter_apply=f_shift.*hf;
image_orignal=ifftshift(filter_apply);
image_filter_apply=abs(ifft2(image_orignal));
figure(2)
imshow(image_filter_apply,[])
title('practical performed by shruti');
figure(3)
mesh(hf)
figure(4)
imagesc(hf),colormap(gray);
a=im2double(imread('circuit.tif'));
figure(1)
imshow(a)
title('original image')
[m n]=size(a);
f_transform=fft2(a);
f_shift=fftshift(f_transform);
p=m/2;
q=n/2;
d0=25;
for i=1:m
for j=1:n
distance=sqrt((i-p)^2+(j-q)^2);
high_filter(i,j)=1-exp(-(distance)^2/(2*(d0^2)));
end
end
filter_apply=f_shift.*high_filter;
image_orignal=ifftshift(filter_apply);
image_filter_apply=abs(ifft2(image_orignal));
figure(2)
imshow(image_filter_apply,[])
title('practical performed by
shruti')
figure(4)
imagesc(high_filter),colormap(gray);
0 comments:
Confused? Feel free to ask
Post a Comment