How to convert an ideal filter to a non-ideal filter?

1 vue (au cours des 30 derniers jours)
Ayberk Ay
Ayberk Ay le 20 Fév 2020
Commenté : Devineni Aslesha le 25 Fév 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');

Réponse acceptée

Devineni Aslesha
Devineni Aslesha le 24 Fév 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 commentaires
Ayberk Ay
Ayberk Ay le 24 Fév 2020
thank you so much, it worked so well and it has better result than ideal filter (I wanted to see this anyways).However PNSR value between original img and noisy img is bigger than the value between original img and filtered img and it is not good at all for filtering.How can I make a better notch filter to remove periodic noises at 'woman-1_3.bmp'?
Devineni Aslesha
Devineni Aslesha le 25 Fév 2020
Please use the following link to design a notch filter.

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by