26K views

Uploaded by Leonardo O Iheme

Simple Implimentation of Band Pass filters using Matlab

- Two Dmension Sgnal and Image Processing by Jae s. Lim
- Image Processing in Frequency Domain Using Matlab a Study for Beginners
- Frequency Domain Filtering Image Processing
- Matlab Image Noises algorithms explained and manually implementation
- Gaussian Noise & All Filters(Matlab Code)
- Fundamentals of Digital Image Processing - A Practical Approach With Examples in Matlab
- Image Restoration
- An Introduction to Digital Image Processing With Matlab
- Digital Image Processing Question Answer Bank
- Digital Image Processing Using Matlab By Gonzalez.pdf
- Uniform Noise & All Filters(Matlab Code)
- Matlab Code for Gaussian Filter in Digital Image Processing
- Digital Image Processing Using Matlab: Basic transformations, filters, operators
- ANTI-ALIASING FILTER DESIGN USING MATLAB, AN IMAGE PROCESSING PROJECT
- Digital Image Processing
- High Boost Filtering
- Matlab
- Exponential Noise & All Filters(Matlab Code)
- Noise Models in Image processing
- Noise Removal in Medical Images

You are on page 1of 10

EE 583 (Digital Image Processing)

Home Work IV

PREPARED BY:

LEONARDO O. IHEME

(106054)

SUBMITTED TO:

Frequency Domain Filtering

Frequency filtering is based on the Fourier Transform. The operator usually takes an image

and a filter function in the Fourier domain. This image is then multiplied with the filter

( ) ( ) ( )

where ( ) is the input image in the Fourier domain, ( ) the filter function and G(k,l)

is the filtered image. To obtain the resulting image in the spatial domain, ( ) has to be re-

transformed using the inverse Fourier Transform. Since the multiplication in the Fourier

space is identical to convolution in the spatial domain, all frequency filters can in theory be

implemented as a spatial filter. However, in practice, the Fourier domain filter function can

A bandpass attenuates very low and very high frequencies, but retains a middle range band of

frequencies. Bandpass filtering can be used to enhance edges (suppressing low frequencies)

while reducing the noise at the same time (attenuating high frequencies). We obtain the filter

function of a bandpass by multiplying the filter functions of a low pass and of a high pass in

the frequency domain, where the cut-off frequency of the low pass is higher than that of the

high pass. Therefore in theory, one can derive a bandpass filter function if the low pass filter

function is available.

Bandpass filtering is attractive but there is always a trade-off between blurring and noise: low

pass reduces noise but accentuates blurring, high pass reduces blurring but accentuates noise

Ideal Bandpass Filter

The ideal bandpass filter passes only frequencies within the pass band and gives an output in

the spatial domain that is in most cases blurred and/or ringed. It is the easiest bandpass filter

to simulate but its vertical edges and sharp corners are not realizable in the physical world.

( )

( ) {

The following example demonstrates the effect of applying an ideal bandpass filter with cut

Image filter function

As expected, the ideal filter has the effect of ringing and blurring on the original image. The

clc

clear all

close all

ima=imread('grass2.jpg');

ima = double(ima);

figure

subplot(221)

imshow(ima,[]);

title('Original image');

imafft = fftshift(fft2(fftshift(ima)));

% Fourier Spectrum of Image

imafft2 = fft2(ima);

imafft3 = fftshift(imafft2);

s = size(ima);

ma=max(max((imafft)));

maxr = 0.5*sqrt(s(1)^2+s(2)^2);

cutoff1 = maxr*30;

cutoff2 = maxr*120;

c=1;

for i = 1 : s(1)

for j = 1 : s(2)

r = sqrt((i-1-s(1)/2)^2+(j-1-s(2)/2)^2);

if ( r < 30)

z(i,j) = 0;

else

if ( r > 120)

z(i,j) = 0;

else

z(i,j) =255;

end

end

end

end

% Plots

subplot(222)

imafft=imafft.*z/255;

ima_out = fftshift(ifft2(fftshift(imafft)));

ima_out =ima_out-ima;

fftshow(ima_out,'abs');

title('Filtered image (Ideal)');

subplot(223)

fftshow(imafft3, 'log');

title('Fourier Spectrum of Image')

subplot(224)

fftshow(z,'log');

title('Filtered');

Butterworth Bandpass Filter

This filter can be derived mathematically by multiplying the transfer functions of a a low and

high pass filter. The low pass filter will have the higher cut off frequency.

( )

( )⁄

( )

( )⁄

( ) ( ) ( )

where are the cut frequencies of the low and high pass filters respectively; is

the order of the filter and ( ) is the distance from the origin.

The Butterworth filter has a “smooth” transfer function without any discontinuity or clear cut

off frequency. The range of frequencies that the filter allows is largely dependent on the order

of the filter. In the selection of there has to be a compromise between the demands of the

frequency domain (sharp cutoff) and the spatial domain (rapid decay).

The example presented in this section demonstrates the effect of applying a fourth order

Butterworth filter with cut off frequencies 30 and 120 to a 256×256 grey scale image.

Figure 2c: Frequency domain filter function

The result shows that the ringing and blurring effect that was observed with the ideal banpass

filter does not exist for the Butterworth filter. The Matlab code is presented below:

clear all;

close all;

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;

for i = 1:2*nx-1

for j =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,[])

The Gaussian filter out-performs the previously discussed filter types because when a

Gaussian is transformed between the frequency and spatial domains, it remains a Gaussian;

and therefore does not incur the ringing effect in the spatial domain of the filtered image.

Again the derivation of a Gaussian bandpass filter starts from the lowpass filter

( ) ( )

( ) ( )

( ) ( ) ( )

where are the cut frequencies of the low and high pass filters respectively;

The example below shows that the Gaussian bandpass filter is the best among the three

discussed filters

Figure 3a: Original Image Figure 3b: Filtered Image

clear all;

close all;

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;

for i = 1:2*nx-1

for j =1:2*ny-1

dist = ((i-(nx+1))^2 + (j-(ny+1))^2)^.5;

% Use Gaussian filter.

filter1(i,j) = exp(-dist^2/(2*120^2));

filter2(i,j) = exp(-dist^2/(2*30^2));

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,[])

Conclusion

From the human perspective, the Gaussian filter would be the most appropriate filter for

filtering. Determining which filter to use is dependent on the application so desired. The

figure below shows the different filters and the result of their application to the grey scale

image.

Figure 4a: Ideal Bandpass Figure 4b: Butterworth Figure 4c: Gaussian

Filter Bandpass Filter Bandpass Filter

Figure 4d: Original Image

Figure 4e: Ideal Filtered Figure 4g: Gaussian Filtered

Filtered

References

[1] McAndrew A., “An Introduction to Digital Image Processing with Matlab Notes for

SCM2511 Image Processing 1”, School of Computer Science and Mathematics,

Victoria University of Technology.

[2] Demirel H., “Digital Image Processing Notes (Lecture 4)” Electrical and Electronic

Engineering, Eastern Mediterranean University, Spring 2010-2011.

[3] Filters (Frequency). (n.d.). Medical Image Processing, Analysis and Visualization.

Retrieved March 26, 2011, from

http://mipav.cit.nih.gov/documentation/HTML%20Algorithms/FiltersFrequency.html

Server. Retrieved March 26, 2011, from

http://homepages.inf.ed.ac.uk/rbf/HIPR2/freqfilt.htm

[5] Anbajafari S., “Bandpass Filter for Image Processing”, Mathworks file exchange, 30

Nov 2008.

- Two Dmension Sgnal and Image Processing by Jae s. LimUploaded bysrm_nizami
- Image Processing in Frequency Domain Using Matlab a Study for BeginnersUploaded byamii628
- Frequency Domain Filtering Image ProcessingUploaded bySankalp_Kallakur_402
- Matlab Image Noises algorithms explained and manually implementationUploaded bySufiyan Ghori
- Gaussian Noise & All Filters(Matlab Code)Uploaded bySharath Kumar N
- Fundamentals of Digital Image Processing - A Practical Approach With Examples in MatlabUploaded bysamia
- Image RestorationUploaded byresmi_ng
- An Introduction to Digital Image Processing With MatlabUploaded byitssiraj
- Digital Image Processing Question Answer BankUploaded bykarpagamkj7595
- Digital Image Processing Using Matlab By Gonzalez.pdfUploaded bysriperl
- Uniform Noise & All Filters(Matlab Code)Uploaded bySharath Kumar N
- Matlab Code for Gaussian Filter in Digital Image ProcessingUploaded bygeonav_had
- Digital Image Processing Using Matlab: Basic transformations, filters, operatorsUploaded byThanh Nguyen
- ANTI-ALIASING FILTER DESIGN USING MATLAB, AN IMAGE PROCESSING PROJECTUploaded bySerdar7tepe
- Digital Image ProcessingUploaded byainugiri
- High Boost FilteringUploaded byK.R.Raguram
- MatlabUploaded byappurono
- Exponential Noise & All Filters(Matlab Code)Uploaded bySharath Kumar N
- Noise Models in Image processingUploaded bypi194043
- Noise Removal in Medical ImagesUploaded byapi-26210692
- Salt & Pepper Noise & All Filters(Matlab Code)Uploaded bySharath Kumar N
- Digital image processing Lab manualUploaded byAnubhav Shrivastava
- Image Processing Using MATLABUploaded byamadeus99
- Low pass filtering, high pass filtering, band pass filtering of an image along with Matlab code.Uploaded byKowshik Reddy Biradavolu
- HW3(Edge Detection Techniques)Uploaded byLeonardo O Iheme
- Digital Image Processing_S. Jayaraman, S. Esakkirajan and T. VeerakumarUploaded byPurushotham Prasad K
- Introduction to Matlab - Image Processing By Dhananjay K. TheckedathUploaded byapi-3768869
- Laboratory Projects_DIP3EUploaded bycycliccrap
- Pre Processing Filters Matlab CodeUploaded bySaba
- Matlab Code for Edge DetectionUploaded byBarnita Sharma

- KISSsoft2Uploaded byChetan Prajapati
- 3. Classification of Elements and Periodicity in PropertiesUploaded bymunuvv123
- 11578_splunk-on-red-hat-gluster-storage-for-the-win.pdfUploaded byIvan CL
- Assignment no 1Uploaded byMudassir Waheed
- Data LoggerUploaded bylaili
- ASP Lecture 3 Estimation Intro 2015Uploaded bykaaashu
- P12 (01) - Fabrication of Polymeric Scaffolds With a Controlled Distribution of PoresUploaded byBenni Wewok
- 604.1.pdfUploaded byrshaghayan
- Adbms BookUploaded byHassan Ali
- shu lesson plan 2Uploaded byapi-278838777
- 2017. When to Remove a Chest TubeUploaded byAlan Espíndola Cruz
- EMTKnodia.pdfUploaded bybinesh
- BMCTANKUploaded byUnilab
- Rainfall Monitoring Using Acoustic SensorsUploaded byfree_mcafee
- redox reactionUploaded byapi-296793567
- Dirichlet Boundary ConditionUploaded byRahul Saha
- 4D Printing Technology: A ReviewUploaded byAfshin Koupaei
- NEST2017_AUploaded byGaurav
- Group Contribution Estimation of Activity Coefficient in Non Ideal MixsUploaded byArun Ebenezer
- CSC Final Exam Study SheetUploaded byThess Dimalibot Bengua
- wie232-wie485_enUploaded byHafidz Huda
- 1.docUploaded byrashandilya
- Charge PumpsUploaded byBLUEE009
- Alsina, Nelsen - Charming ProofsUploaded byAbecedario
- Phase 2 Paper Nav Arch -2Uploaded byThapliyal Sanjay
- Hp Dv6000 No PowerUploaded byangel14864
- Properties of Polyhydroxy Butyrate Polyvalerate Biopolymeric Nanocomposites Reinforced With Natural Halloysite NanotubesUploaded byAbdullah Fahim
- zamil DY_series.pdfUploaded bygagokapala
- Bureau of Energy EfficiencyUploaded byThirumal
- adrian martin zufri heart beatUploaded byapi-346252669