Name: ANUJ SINGH
Roll No: BT17ECE016
ASSIGNMENT 6
Aim:
Program to demonstrate the effect of using Ideal high pass filter and Gaussian high pass filter.
code:
%BT17ECE016
%ANUJ SINGH
clc;
close all;
clear all;
an=double(imread('[Link]'));
F_u_v=fft2(an);
F_u_v=(fftshift(F_u_v));
subplot(3,3,1);imshow(uint8(an));
title('Image');
temp=log(abs(F_u_v));
subplot(3,3,2);
imshow(temp,[]);
title('Fourier domain image');
[M,N]=size(an);
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);
D0=5;
H =ifftshift(double(D <=D0));
Hp=1-H;
g=real(ifft2(Hp.*F_u_v));
subplot(3,3,3);imshow(uint8(abs(g)));
title('Image after filtering');
subplot(3,3,4);imshow(Hp,[]);
title('Highpass filter with cutoff=5');
D0=10;
H= ifftshift(exp(-(D.^2)./(2*(D0^2))));
Hgh=1-H;
g=real(ifft2(Hgh.*F_u_v));
subplot(3,3,5);imshow(uint8(abs(g)));
title('Image after filtering');
subplot(3,3,6);imshow(Hgh,[]);
title('Gaussian Highpass filtered image');
OUTPUTS:
ASSIGNMENT 7
Aim:
Program to demonstrate the effect of ringing effect in an image by using a low pass filter also
how it can be avoided.
code:
%BT17ECE016
%ANUJ SINGH
clc
clear all
close all
an=imread('[Link]');
);
a=imresize(an,[256 256]);
af=fftshift(fft2(a));
subplot(331);
fftshow(af)
title('Image
'Image in frequency domain'
domain');
[x,y]=meshgrid(-128:127,
128:127,-128:127);
z=sqrt(x.^2+y.^2);
c=z<24;
af1=af.*c;
subplot(332)
fftshow(af1)
title('Low pass filter image');
afi=ifft2(af1);
subplot(333)
ifftshow(afi)
title('Filtered image');
lp=butterip(a,15,1);
aflp=af.*lp;
af=ifft2(aflp);
subplot(335)
ifftshow(af)
title('butterworth results');
OUTPUTS: