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

조회 수: 4 (최근 30일)
Ayberk Ay
Ayberk Ay 2020년 2월 20일
댓글: Devineni Aslesha 2020년 2월 25일
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');

채택된 답변

Devineni Aslesha
Devineni Aslesha 2020년 2월 24일
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
Ayberk Ay
Ayberk Ay 2020년 2월 24일
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 2020년 2월 25일
Please use the following link to design a notch filter.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by