convert band pass to band reject

3 visualizaciones (últimos 30 días)
mecheal
mecheal el 16 de Jul. de 2013
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,[])

Respuesta aceptada

Image Analyst
Image Analyst el 16 de Jul. de 2013
Just invert the filter. Make filter3 = 1-filter3. Try that.
  1 comentario
mecheal
mecheal el 16 de Jul. de 2013
do u trace my code ? is it correct ? how can i identify the frequencies that included in the rejected band ??

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by