convert band pass to band reject

3 ビュー (過去 30 日間)
mecheal
mecheal 2013 年 7 月 16 日
i've this code for band pass filter ,any one can convert it to band reject filter ??
% Bandpass Butterworth Filter
clearall;
closeall;
clc
micro = imread('grass2.jpg');
micro = double(micro);
[nx ny] = size(micro);
nx
ny
u = micro;
micro = uint8(u);
imwrite(micro,'grass5.jpg');
fftu = fft2(u,2*nx-1,2*ny-1);
fftu = fftshift(fftu);
subplot(2,2,1)
imshow(micro,[]);
subplot(2,2,2)
fftshow(fftu,'log')
% Initialize filter.
filter1 = ones(2*nx-1,2*ny-1);
filter2 = ones(2*nx-1,2*ny-1);
filter3 = ones(2*nx-1,2*ny-1);
n = 4;
fori = 1:2*nx-1
forj =1:2*ny-1
dist = ((i-(nx+1))^2 + (j-(ny+1))^2)^.5;
% Use Butterworth filter.
filter1(i,j)= 1/(1 + (dist/120)^(2*n));
filter2(i,j) = 1/(1 + (dist/30)^(2*n));
filter3(i,j)= 1.0 - filter2(i,j);
filter3(i,j) = filter1(i,j).*filter3(i,j);
end
end
% Update image with passed frequencies.
fil_micro = fftu + filter3.*fftu;
subplot(2,2,3)
fftshow(filter3,'log')
fil_micro = ifftshift(fil_micro);
fil_micro = ifft2(fil_micro,2*nx-1,2*ny-1);
fil_micro = real(fil_micro(1:nx,1:ny));
fil_micro = uint8(fil_micro);
subplot(2,2,4)
imshow(fil_micro,[])

採用された回答

Image Analyst
Image Analyst 2013 年 7 月 16 日
Just invert the filter. Make filter3 = 1-filter3. Try that.
  1 件のコメント
mecheal
mecheal 2013 年 7 月 16 日
do u trace my code ? is it correct ? how can i identify the frequencies that included in the rejected band ??

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDigital Filter Design についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by