How to convert an ideal filter to a non-ideal filter?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ayberk Ay
am 20 Feb. 2020
Kommentiert: Devineni Aslesha
am 25 Feb. 2020
Hey, everyone! My goal on this code is making non ideal filter with doing convolution of the notch filter and average filter. My teacher said this method. However,I do not know how to use 'C' part (convolution) to show as 'Output of Notch Filter'. (I know it will not be notch filter anymore after convolution but don't mind the name of the output). Please help me, this is for lab report and so important. I've tried to replace filt to C in 'imshow(log(1+abs( fftshift(I2).*filt)),[]);' part but I've got a error, can you fix this problem? Thanks for your attention.
Image is attached.
I = imread('woman-1_3.bmp');
I2=fft2(I);
imshow(log(1+abs(fftshift(I2))),[]);
%Notch Filter (Ideal Filter)
filt=ones(200);
filt(87:1:91,87:1:91)=0;
filt(112:1:116,87:1:91)=0;
filt(113:1:115,111:1:113)=0;
filt(87:1:91,111:1:113)=0;
imshow(filt);
% Making non-ideal filter using convolution
filter_av = ones(3,3)/9;
C = conv2(filter_av,filt,'same');
imshow(log(1+abs( fftshift(I2).*filt)),[]);
subplot(121),imshow(I),title('Noisy Image');
subplot(122),imshow(log(1+abs(ifft2( fftshift(I2).*filt))),[]),title('Output of Notch Filter');
0 Kommentare
Akzeptierte Antwort
Devineni Aslesha
am 24 Feb. 2020
In the above code, the size of C is 3*3 due to the selection of the ‘shape’ in ‘conv2’ function as ‘same’. However, selecting the ‘shape’ in ‘conv2’ function as ‘full’, gives 'C' as output with size 202*202. Please use the below code to solve the error occurred while using 'C' in imshow.
C = conv2(filter_av,filt,'full');
Also, replace 'filt' with 'C' as shown below.
imshow(log(1+abs(ifft2( fftshift(I2).*C(1:200,1:200)))),[])
2 Kommentare
Devineni Aslesha
am 25 Feb. 2020
Please use the following link to design a notch filter.
Weitere Antworten (0)
Siehe auch
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!