SlideShare a Scribd company logo
1 of 16
Download to read offline
NATIONAL CHENG KUNG UNIVERSITY
Inst. of Manufacturing Information & Systems
DIGITAL IMAGE PROCESSING AND SOFTWARE IMPLEMENTATION
HOMEWORK 2
Professor name: Chen, Shang-Liang
Student name: Nguyen Van Thanh
Student ID: P96007019
Class: P9-009 Image Processing and Software Implementation
Time: [4] 2  4
1
Contents
PROBLEM 2
SOLUTION 3
1. Fourier transform 3
1.1. The 2 – D DFT and its inverse 3
2. Frequency domain smoothing filters 5
2.1. Ideal low-pass filters (ILPF) 5
2.2. Butterworth low-pass filter (BLPF) 6
2.3. Gaussian low-pass filter (GLPF) 8
3. Sharpening frequency domain filters 9
3.1. Ideal high-pass filters (IHPF) 9
3.2. Butterworth high-pass filters (BHPF) 10
3.3. Gaussian high-pass filters (GHPF) 11
4. Homomorphic filtering 13
REFERENCES 15
2
PROBLEM
影像處理與軟體實現[HW2]
課程碼:P953300 授課教授:陳響亮 教授 助教:陳怡瑄 日期:2011/04/07
題目:請以C# 撰寫一程式,可讀入一影像檔,並可執行以下之影像
頻率域之影像增強功能。
a. 每一程式需設計一適當之人機操作介面。
b. 每一功能請以不同方法分開撰寫,各項參數需讓使用者自行輸入。
c. 以C# 撰寫時,可直接呼叫Matlab 現有函式,但呼叫多寡,將列為評分考
量。
(呼叫越少,分數越高)
d. 本次作業視同三次平時作業成績。
一、 傅立葉轉換
1. 二維的DFT及其反轉換
二、 頻率域的平滑濾波器
1. 理想低通濾波器
2. 巴特沃斯低通濾波器
3. 高斯低通濾波器
三、 頻率域濾波器的銳化
1. 理想高通濾波器
2. 巴特沃斯高通濾波器
3. 高斯高通濾波器
四、 同態濾波
◎繳交日期:請於2011/04/21 am9:00以前準時繳交。
◎Word檔內容:需包含程式片段與執行結果之說明。
◎檔案繳交格式:Word檔與程式檔進行壓縮一併繳交。
◎檔案名稱格式:[HW-X]學號。例:[HW-1]P96981035。
◎檔案請上傳至:140.116.86.200;port:21;帳號密碼皆為:image。
3
SOLUTION
1. Fourier transform
1.1. The 2 – D DFT and its inverse
In Matlab, there is a function that can compute the 1 – D DFT, the function is fft. The syntax of the
function is,
F = fft (f)
For f is a matrix, so fft function returns the Fourier transform of each column of the matrix. Refer to the
reference [1], so we can use the function fft for computing the 2 – D DFT by first computing a 1 – D DFT
along each column of the input image f, and then computing a 1 – D DFT along each row of this
intermediate result. So the function dft below, that computes the 2 – D DFT by following the reason
above,
function [s, sc, slog] = dft(f)
F1 = fft(f); % 1-D column transforms
F2 = F1';
F = fft(F2) % 1-D row transforms
s = abs(F); % obtaining the Fourier spectrum
Fc = fftshift(F); % fftshift is function that can be used to move the
% origin of the transform to the center of frequency
% rectangle
sc = abs(Fc); % the Fourier spectrum of Fc
slog = log(1 + sc); % log transform
subplot(2,3,1); imshow(f);
subplot(2,3,2); imshow(s, [ ]);
subplot(2,3,4); imshow(sc, [ ]);
subplot(2,3,5); imshow(slog, [ ]);
We type the command,
>> f = imread (‘Fig4.03(a).jpg’);
>> [s, sc, slog] = dft (f)
4
It yields the images below,
Similarly, the inverse Fourier transform is computed by using function idft below,
function g = idft(F)
% Note that: we ignore imaginary part of input F, F is the Fourier
% transform and f is the resulting image.
g1 = ifft(F);
g2 = g1';
g = im2uint8(ifft(g2));
imshow(g)
We also use the function fft2 in Matlab to obtain directly the 2 – D DFT; fft2 function is the Fast Fourier
Transform. In fact, the DFT and its inverse are obtained by using a FFT algorithm. And, the inverse of FFT
is obtained by using the function ifft2. Hereafter, we would like to use the FFT.
5
2. Frequency domain smoothing filters
We would like to show the basic steps for filtering in the frequency domain as the diagram below,
Pre-
processing
Fourier
transform
Filter
function
H(u,v)
Pre-
processing
Inverse
Fourier
transform
f(x,y)
Input image
g(x,y)
Enhanced image
F(u,v) H(u,v)F(u,v)
2.1. Ideal low-pass filters (ILPF)
With ILPF case, the filter function H (u, v) is defined as,
1 if D (u, v) ≤ D0
H (u, v) =
0 if D (u, v) ≥ D0
Where D (u, v) is the distance from any point (u, v) to the center (origin) of the Fourier transform and it is
given by,
D (u, v) = sqrt (u2
+ v2
)
And D0 is a specified distance from the origin of the (centered) transform.
We write a function to compute the ILPF, this function name is ilpf,
function g = ilpf(f,D0)
[M,N]=size(f);
F=fft2(double(f));
u=0:(M-1);
v=0:(N-1);
idx=find(u>M/2);
u(idx)=u(idx)-M;
6
idy=find(v>N/2);
v(idy)=v(idy)-N;
[V,U]=meshgrid(v,u);
D=sqrt(U.^2+V.^2);
H=double(D<=D0);
G=H.*F;
g=real(ifft2(double(G)));
subplot(1,2,1); imshow(f); title('Input image');
subplot(1,2,2); imshow(g,[ ]); title('Enhanced image');
end
We type the command,
>> f = imread (‘Fig4.11(a).jpg’);
>> g = ilpf (f, 30);
It yields the images below,
2.2. Butterworth low-pass filter (BLPF)
With the BLPF, the filter function H (u, v) is,
( )
( )
7
Where n is the order.
We write a function to compute the BLPF, this function name is blpf,
function g = blpf(f,n,D0)
[M,N]=size(f);
F=fft2(double(f));
u=0:(M-1);
v=0:(N-1);
idx=find(u>M/2);
u(idx)=u(idx)-M;
idy=find(v>N/2);
v(idy)=v(idy)-N;
[V,U]=meshgrid(v,u);
D=sqrt(U.^2+V.^2);
H = 1./(1 + (D./D0).^(2*n));
G=H.*F;
g=real(ifft2(double(G)));
subplot(1,2,1); imshow(f); title('Input image');
subplot(1,2,2); imshow(g,[ ]); title('Enhanced image');
end
We type the command,
>> f = imread (‘Fig4.11(a).jpg’);
>> g = blpf (f, 2, 30);
It yields the images below,
8
2.3. Gaussian low-pass filter (GLPF)
With the GLPF, the filter function H (u, v) is,
( ) ( ) ( )
We write a function to compute the BLPF, this function name is blpf,
function g = glpf(f,D0)
[M,N]=size(f);
F=fft2(double(f));
u=0:(M-1);
v=0:(N-1);
idx=find(u>M/2);
u(idx)=u(idx)-M;
idy=find(v>N/2);
v(idy)=v(idy)-N;
[V,U]=meshgrid(v,u);
D=sqrt(U.^2+V.^2);
H = exp(-(D.^2)./(2*(D0^2)));
G=H.*F;
g=real(ifft2(double(G)));
subplot(1,2,1); imshow(f); title('Input image');
subplot(1,2,2); imshow(g,[ ]); title('Enhanced image');
end
We type the command,
>> f = imread (‘Fig4.11(a).jpg’);
>> g = glpf (f, 30);
It yields the images below,
9
3. Sharpening frequency domain filters
Image sharpening can be achieved in the frequency domain by a high-pass filtering process. The high-
pass filter function, Hhp (u, v) is defined as,
Hhp (u, v) = 1 – Hlp (u, v)
3.1. Ideal high-pass filters (IHPF)
With the reason above, we can obtain the IHPF from the ILPF by changing the filter function H (u, v). The
function to compute the IHPF is,
function g = ihpf(f,D0)
[M,N]=size(f);
F=fft2(double(f));
u=0:(M-1);
v=0:(N-1);
idx=find(u>M/2);
u(idx)=u(idx)-M;
idy=find(v>N/2);
v(idy)=v(idy)-N;
[V,U]=meshgrid(v,u);
D=sqrt(U.^2+V.^2);
H=double(D<=D0);
H=1-H;
G=H.*F;
10
g=real(ifft2(double(G)));
subplot(1,2,1); imshow(f); title('Input image');
subplot(1,2,2); imshow(g,[ ]); title('Enhanced image');
end
We type the command,
>> f = imread (‘Fig4.11(a).jpg’);
>> g = ihpf (f, 15);
It yields the images below,
3.2. Butterworth high-pass filters (BHPF)
The filter function of the BHPF of order n and with cutoff frequency locus at distance D0 from the origin is
given by,
( )
( )
We change the filter function H (u,v) in the BLPF for obtaining the BHPF. Here is the BHPF function,
function g = bhpf(f,n,D0)
[M,N]=size(f);
F=fft2(double(f));
u=0:(M-1);
v=0:(N-1);
idx=find(u>M/2);
11
u(idx)=u(idx)-M;
idy=find(v>N/2);
v(idy)=v(idy)-N;
[V,U]=meshgrid(v,u);
D=sqrt(U.^2+V.^2);
H = 1./(1 + (D0./D).^(2*n));
G=H.*F;
g=real(ifft2(double(G)));
subplot(1,2,1); imshow(f); title('Input image');
subplot(1,2,2); imshow(g,[ ]); title('Enhanced image');
end
We type the command,
>> f = imread (‘Fig4.11(a).jpg’);
>> g = bhpf (f, 2, 15);
It yields the images below,
3.3. Gaussian high-pass filters (GHPF)
The filter function of GHPF with cutoff frequency locus at a distance D0 from the origin is given by,
( ) ( )
We change the filter function H (u,v) in the GLPF for obtaining the BHPF. Here is the GHPF function,
function g = ghpf(f,D0)
[M,N]=size(f);
12
F=fft2(double(f));
u=0:(M-1);
v=0:(N-1);
idx=find(u>M/2);
u(idx)=u(idx)-M;
idy=find(v>N/2);
v(idy)=v(idy)-N;
[V,U]=meshgrid(v,u);
D=sqrt(U.^2+V.^2);
H = 1 - exp(-(D.^2)./(2*(D0^2)));
G=H.*F;
g=real(ifft2(double(G)));
subplot(1,2,1); imshow(f); title('Input image');
subplot(1,2,2); imshow(g,[ ]); title('Enhanced image');
end
We type the command,
>> f = imread (‘Fig4.11(a).jpg’);
>> g = bhpf (f, 15);
It yields the images below,
13
4. Homomorphic filtering
The Homomorphic filtering approach is summaried in the Figure below.
Ln DFT H (u, v) Inverse DFT exp
f(x, y)
Input
immage
g(x, y)
Enhanced
image
Homomorphic filtering approach for
image enhancement
In the Homomorphic filtering, the filter function H (u, v) is varied according to the special purpose. In the
function below, we choose one, that is,
( ) ( ) ( )
Where, H and L are two parameters. Here is the Homomorphic filter function,
function g = homo_filter(f,D0,gamaH,gamaL)
[M,N]=size(f);
u=0:(M-1);
v=0:(N-1);
idx=find(u>M/2);
u(idx)=u(idx)-M;
idy=find(v>N/2);
v(idy)=v(idy)-N;
[V,U]=meshgrid(v,u);
D=sqrt(U.^2+V.^2);
H = 1 - exp(-(D.^2)./(2*(D0^2))); % Gaussian high-pass filter
H = (gamaH - gamaL)*H + gamaL;
14
z = log2(1+double(f)); % Log transfrom
Z = fft2(z);
S=H.*Z;
s=real(ifft2(double(S)));
g = 2.^s;
subplot(1,2,1); imshow(f); title('Input image');
subplot(1,2,2); imshow(g,[ ]); title('Enhanced image');
end
We type the command,
>> f = imread (‘Fig.ex.jpg’);
>> g = homo_filter(f,10,0.5,0.2);
It yields the images below,
15
REFERENCES
1. Rafael C. Gonzalez,.; Woods, R. E., “Digital Image Processing“, Prentice
Hall, 2002.
2. Rafael C. Gonzalez, Richard E. Woods, Steven L; Woods, R. E., “Digital
Image Processing Using MATLAB“, Prentice Hall, 2005.
3. http://www.mathworks.com/
4. http://www.imageprocessingplace.com/index.htm

More Related Content

What's hot

3 intensity transformations and spatial filtering slides
3 intensity transformations and spatial filtering slides3 intensity transformations and spatial filtering slides
3 intensity transformations and spatial filtering slidesBHAGYAPRASADBUGGE
 
Digital Image Processing: Image Enhancement in the Frequency Domain
Digital Image Processing: Image Enhancement in the Frequency DomainDigital Image Processing: Image Enhancement in the Frequency Domain
Digital Image Processing: Image Enhancement in the Frequency DomainMostafa G. M. Mostafa
 
Image Enhancement - Point Processing
Image Enhancement - Point ProcessingImage Enhancement - Point Processing
Image Enhancement - Point ProcessingGayathri31093
 
CV_Chap 6 Motion Representation
CV_Chap 6 Motion RepresentationCV_Chap 6 Motion Representation
CV_Chap 6 Motion RepresentationKhushali Kathiriya
 
5. gray level transformation
5. gray level transformation5. gray level transformation
5. gray level transformationMdFazleRabbi18
 
Image noise reduction
Image noise reductionImage noise reduction
Image noise reductionJksuryawanshi
 
DCT image compression
DCT image compressionDCT image compression
DCT image compressionyoussef ramzy
 
Implementation and comparison of Low pass filters in Frequency domain
Implementation and comparison of Low pass filters in Frequency domainImplementation and comparison of Low pass filters in Frequency domain
Implementation and comparison of Low pass filters in Frequency domainZara Tariq
 
Image Restoration And Reconstruction
Image Restoration And ReconstructionImage Restoration And Reconstruction
Image Restoration And ReconstructionAmnaakhaan
 
DIGITAL IMAGE PROCESSING - Day 4 Image Transform
DIGITAL IMAGE PROCESSING - Day 4 Image TransformDIGITAL IMAGE PROCESSING - Day 4 Image Transform
DIGITAL IMAGE PROCESSING - Day 4 Image Transformvijayanand Kandaswamy
 
Image feature extraction
Image feature extractionImage feature extraction
Image feature extractionRishabh shah
 
Erosion and dilation
Erosion and dilationErosion and dilation
Erosion and dilationAkhil .B
 
Camera model ‫‬
Camera model ‫‬Camera model ‫‬
Camera model ‫‬Fatima Radi
 
Image Processing: Spatial filters
Image Processing: Spatial filtersImage Processing: Spatial filters
Image Processing: Spatial filtersA B Shinde
 
Image trnsformations
Image trnsformationsImage trnsformations
Image trnsformationsJohn Williams
 

What's hot (20)

3 intensity transformations and spatial filtering slides
3 intensity transformations and spatial filtering slides3 intensity transformations and spatial filtering slides
3 intensity transformations and spatial filtering slides
 
Digital Image Processing: Image Enhancement in the Frequency Domain
Digital Image Processing: Image Enhancement in the Frequency DomainDigital Image Processing: Image Enhancement in the Frequency Domain
Digital Image Processing: Image Enhancement in the Frequency Domain
 
Image transforms
Image transformsImage transforms
Image transforms
 
Image Enhancement - Point Processing
Image Enhancement - Point ProcessingImage Enhancement - Point Processing
Image Enhancement - Point Processing
 
CV_Chap 6 Motion Representation
CV_Chap 6 Motion RepresentationCV_Chap 6 Motion Representation
CV_Chap 6 Motion Representation
 
CV_2 Filtering_Example
CV_2 Filtering_ExampleCV_2 Filtering_Example
CV_2 Filtering_Example
 
5. gray level transformation
5. gray level transformation5. gray level transformation
5. gray level transformation
 
Image noise reduction
Image noise reductionImage noise reduction
Image noise reduction
 
DCT image compression
DCT image compressionDCT image compression
DCT image compression
 
Implementation and comparison of Low pass filters in Frequency domain
Implementation and comparison of Low pass filters in Frequency domainImplementation and comparison of Low pass filters in Frequency domain
Implementation and comparison of Low pass filters in Frequency domain
 
image enhancement
 image enhancement image enhancement
image enhancement
 
Image Restoration And Reconstruction
Image Restoration And ReconstructionImage Restoration And Reconstruction
Image Restoration And Reconstruction
 
DIGITAL IMAGE PROCESSING - Day 4 Image Transform
DIGITAL IMAGE PROCESSING - Day 4 Image TransformDIGITAL IMAGE PROCESSING - Day 4 Image Transform
DIGITAL IMAGE PROCESSING - Day 4 Image Transform
 
Image feature extraction
Image feature extractionImage feature extraction
Image feature extraction
 
Erosion and dilation
Erosion and dilationErosion and dilation
Erosion and dilation
 
CV_Chap 3 Features Detection
CV_Chap 3 Features DetectionCV_Chap 3 Features Detection
CV_Chap 3 Features Detection
 
Camera model ‫‬
Camera model ‫‬Camera model ‫‬
Camera model ‫‬
 
Image Processing: Spatial filters
Image Processing: Spatial filtersImage Processing: Spatial filters
Image Processing: Spatial filters
 
Module 2
Module 2Module 2
Module 2
 
Image trnsformations
Image trnsformationsImage trnsformations
Image trnsformations
 

Similar to Digital image processing using matlab: filters (detail)

Forward & Backward Differenece Table
Forward & Backward Differenece TableForward & Backward Differenece Table
Forward & Backward Differenece TableSaloni Singhal
 
04 1 - frequency domain filtering fundamentals
04 1 - frequency domain filtering fundamentals04 1 - frequency domain filtering fundamentals
04 1 - frequency domain filtering fundamentalscpshah01
 
高いChurn耐性と検索性能を持つキー順序保存型構造化オーバレイネットワークSuzakuの提案と評価
高いChurn耐性と検索性能を持つキー順序保存型構造化オーバレイネットワークSuzakuの提案と評価高いChurn耐性と検索性能を持つキー順序保存型構造化オーバレイネットワークSuzakuの提案と評価
高いChurn耐性と検索性能を持つキー順序保存型構造化オーバレイネットワークSuzakuの提案と評価Kota Abe
 
07 frequency domain DIP
07 frequency domain DIP07 frequency domain DIP
07 frequency domain DIPbabak danyal
 
Image Compression Comparison Using Golden Section Transform, CDF 5/3 (Le Gall...
Image Compression Comparison Using Golden Section Transform, CDF 5/3 (Le Gall...Image Compression Comparison Using Golden Section Transform, CDF 5/3 (Le Gall...
Image Compression Comparison Using Golden Section Transform, CDF 5/3 (Le Gall...Jason Li
 
小波变换程序
小波变换程序小波变换程序
小波变换程序byron zhao
 
小波变换程序
小波变换程序小波变换程序
小波变换程序byron zhao
 
Digital Image Processing Module 3 Notess
Digital Image Processing Module 3 NotessDigital Image Processing Module 3 Notess
Digital Image Processing Module 3 Notessshivubhavv
 
Image Compression Comparison Using Golden Section Transform, Haar Wavelet Tra...
Image Compression Comparison Using Golden Section Transform, Haar Wavelet Tra...Image Compression Comparison Using Golden Section Transform, Haar Wavelet Tra...
Image Compression Comparison Using Golden Section Transform, Haar Wavelet Tra...Jason Li
 
Fourier project presentation
Fourier project  presentationFourier project  presentation
Fourier project presentation志璿 楊
 
Info 2234 Chapter 8 -image restoration.pdf
Info 2234 Chapter 8 -image restoration.pdfInfo 2234 Chapter 8 -image restoration.pdf
Info 2234 Chapter 8 -image restoration.pdfahmadzahran219
 
Tao Fayan_Iso and Full_volume rendering
Tao Fayan_Iso and Full_volume renderingTao Fayan_Iso and Full_volume rendering
Tao Fayan_Iso and Full_volume renderingFayan TAO
 
FourierTransform detailed power point presentation
FourierTransform detailed power point presentationFourierTransform detailed power point presentation
FourierTransform detailed power point presentationssuseracb8ba
 
Basic Calculus.docx
Basic Calculus.docxBasic Calculus.docx
Basic Calculus.docxjericranoco
 
Program Derivation of Operations in Finite Fields of Prime Order
Program Derivation of Operations in Finite Fields of Prime OrderProgram Derivation of Operations in Finite Fields of Prime Order
Program Derivation of Operations in Finite Fields of Prime OrderCharles Southerland
 
imagetransforms1-210417050321.pptx
imagetransforms1-210417050321.pptximagetransforms1-210417050321.pptx
imagetransforms1-210417050321.pptxMrsSDivyaBME
 

Similar to Digital image processing using matlab: filters (detail) (20)

Forward & Backward Differenece Table
Forward & Backward Differenece TableForward & Backward Differenece Table
Forward & Backward Differenece Table
 
04 1 - frequency domain filtering fundamentals
04 1 - frequency domain filtering fundamentals04 1 - frequency domain filtering fundamentals
04 1 - frequency domain filtering fundamentals
 
高いChurn耐性と検索性能を持つキー順序保存型構造化オーバレイネットワークSuzakuの提案と評価
高いChurn耐性と検索性能を持つキー順序保存型構造化オーバレイネットワークSuzakuの提案と評価高いChurn耐性と検索性能を持つキー順序保存型構造化オーバレイネットワークSuzakuの提案と評価
高いChurn耐性と検索性能を持つキー順序保存型構造化オーバレイネットワークSuzakuの提案と評価
 
07 frequency domain DIP
07 frequency domain DIP07 frequency domain DIP
07 frequency domain DIP
 
Image Compression Comparison Using Golden Section Transform, CDF 5/3 (Le Gall...
Image Compression Comparison Using Golden Section Transform, CDF 5/3 (Le Gall...Image Compression Comparison Using Golden Section Transform, CDF 5/3 (Le Gall...
Image Compression Comparison Using Golden Section Transform, CDF 5/3 (Le Gall...
 
小波变换程序
小波变换程序小波变换程序
小波变换程序
 
小波变换程序
小波变换程序小波变换程序
小波变换程序
 
Image transforms
Image transformsImage transforms
Image transforms
 
Digital Image Processing Module 3 Notess
Digital Image Processing Module 3 NotessDigital Image Processing Module 3 Notess
Digital Image Processing Module 3 Notess
 
Image Compression Comparison Using Golden Section Transform, Haar Wavelet Tra...
Image Compression Comparison Using Golden Section Transform, Haar Wavelet Tra...Image Compression Comparison Using Golden Section Transform, Haar Wavelet Tra...
Image Compression Comparison Using Golden Section Transform, Haar Wavelet Tra...
 
Fourier project presentation
Fourier project  presentationFourier project  presentation
Fourier project presentation
 
Info 2234 Chapter 8 -image restoration.pdf
Info 2234 Chapter 8 -image restoration.pdfInfo 2234 Chapter 8 -image restoration.pdf
Info 2234 Chapter 8 -image restoration.pdf
 
VCU(Seminar)
VCU(Seminar)VCU(Seminar)
VCU(Seminar)
 
Tao Fayan_Iso and Full_volume rendering
Tao Fayan_Iso and Full_volume renderingTao Fayan_Iso and Full_volume rendering
Tao Fayan_Iso and Full_volume rendering
 
FourierTransform detailed power point presentation
FourierTransform detailed power point presentationFourierTransform detailed power point presentation
FourierTransform detailed power point presentation
 
matlab.docx
matlab.docxmatlab.docx
matlab.docx
 
Basic Calculus.docx
Basic Calculus.docxBasic Calculus.docx
Basic Calculus.docx
 
Program Derivation of Operations in Finite Fields of Prime Order
Program Derivation of Operations in Finite Fields of Prime OrderProgram Derivation of Operations in Finite Fields of Prime Order
Program Derivation of Operations in Finite Fields of Prime Order
 
DFT.ppt
DFT.pptDFT.ppt
DFT.ppt
 
imagetransforms1-210417050321.pptx
imagetransforms1-210417050321.pptximagetransforms1-210417050321.pptx
imagetransforms1-210417050321.pptx
 

Recently uploaded

INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
Expanded definition: technical and operational
Expanded definition: technical and operationalExpanded definition: technical and operational
Expanded definition: technical and operationalssuser3e220a
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxlancelewisportillo
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmStan Meyer
 
The Contemporary World: The Globalization of World Politics
The Contemporary World: The Globalization of World PoliticsThe Contemporary World: The Globalization of World Politics
The Contemporary World: The Globalization of World PoliticsRommel Regala
 
EMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docxEMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docxElton John Embodo
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfVanessa Camilleri
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSMae Pangan
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptxmary850239
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptshraddhaparab530
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfErwinPantujan2
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 

Recently uploaded (20)

INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
Expanded definition: technical and operational
Expanded definition: technical and operationalExpanded definition: technical and operational
Expanded definition: technical and operational
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptxINCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and Film
 
The Contemporary World: The Globalization of World Politics
The Contemporary World: The Globalization of World PoliticsThe Contemporary World: The Globalization of World Politics
The Contemporary World: The Globalization of World Politics
 
EMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docxEMBODO Lesson Plan Grade 9 Law of Sines.docx
EMBODO Lesson Plan Grade 9 Law of Sines.docx
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdf
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHS
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Integumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.pptIntegumentary System SMP B. Pharm Sem I.ppt
Integumentary System SMP B. Pharm Sem I.ppt
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 

Digital image processing using matlab: filters (detail)

  • 1. NATIONAL CHENG KUNG UNIVERSITY Inst. of Manufacturing Information & Systems DIGITAL IMAGE PROCESSING AND SOFTWARE IMPLEMENTATION HOMEWORK 2 Professor name: Chen, Shang-Liang Student name: Nguyen Van Thanh Student ID: P96007019 Class: P9-009 Image Processing and Software Implementation Time: [4] 2  4
  • 2. 1 Contents PROBLEM 2 SOLUTION 3 1. Fourier transform 3 1.1. The 2 – D DFT and its inverse 3 2. Frequency domain smoothing filters 5 2.1. Ideal low-pass filters (ILPF) 5 2.2. Butterworth low-pass filter (BLPF) 6 2.3. Gaussian low-pass filter (GLPF) 8 3. Sharpening frequency domain filters 9 3.1. Ideal high-pass filters (IHPF) 9 3.2. Butterworth high-pass filters (BHPF) 10 3.3. Gaussian high-pass filters (GHPF) 11 4. Homomorphic filtering 13 REFERENCES 15
  • 3. 2 PROBLEM 影像處理與軟體實現[HW2] 課程碼:P953300 授課教授:陳響亮 教授 助教:陳怡瑄 日期:2011/04/07 題目:請以C# 撰寫一程式,可讀入一影像檔,並可執行以下之影像 頻率域之影像增強功能。 a. 每一程式需設計一適當之人機操作介面。 b. 每一功能請以不同方法分開撰寫,各項參數需讓使用者自行輸入。 c. 以C# 撰寫時,可直接呼叫Matlab 現有函式,但呼叫多寡,將列為評分考 量。 (呼叫越少,分數越高) d. 本次作業視同三次平時作業成績。 一、 傅立葉轉換 1. 二維的DFT及其反轉換 二、 頻率域的平滑濾波器 1. 理想低通濾波器 2. 巴特沃斯低通濾波器 3. 高斯低通濾波器 三、 頻率域濾波器的銳化 1. 理想高通濾波器 2. 巴特沃斯高通濾波器 3. 高斯高通濾波器 四、 同態濾波 ◎繳交日期:請於2011/04/21 am9:00以前準時繳交。 ◎Word檔內容:需包含程式片段與執行結果之說明。 ◎檔案繳交格式:Word檔與程式檔進行壓縮一併繳交。 ◎檔案名稱格式:[HW-X]學號。例:[HW-1]P96981035。 ◎檔案請上傳至:140.116.86.200;port:21;帳號密碼皆為:image。
  • 4. 3 SOLUTION 1. Fourier transform 1.1. The 2 – D DFT and its inverse In Matlab, there is a function that can compute the 1 – D DFT, the function is fft. The syntax of the function is, F = fft (f) For f is a matrix, so fft function returns the Fourier transform of each column of the matrix. Refer to the reference [1], so we can use the function fft for computing the 2 – D DFT by first computing a 1 – D DFT along each column of the input image f, and then computing a 1 – D DFT along each row of this intermediate result. So the function dft below, that computes the 2 – D DFT by following the reason above, function [s, sc, slog] = dft(f) F1 = fft(f); % 1-D column transforms F2 = F1'; F = fft(F2) % 1-D row transforms s = abs(F); % obtaining the Fourier spectrum Fc = fftshift(F); % fftshift is function that can be used to move the % origin of the transform to the center of frequency % rectangle sc = abs(Fc); % the Fourier spectrum of Fc slog = log(1 + sc); % log transform subplot(2,3,1); imshow(f); subplot(2,3,2); imshow(s, [ ]); subplot(2,3,4); imshow(sc, [ ]); subplot(2,3,5); imshow(slog, [ ]); We type the command, >> f = imread (‘Fig4.03(a).jpg’); >> [s, sc, slog] = dft (f)
  • 5. 4 It yields the images below, Similarly, the inverse Fourier transform is computed by using function idft below, function g = idft(F) % Note that: we ignore imaginary part of input F, F is the Fourier % transform and f is the resulting image. g1 = ifft(F); g2 = g1'; g = im2uint8(ifft(g2)); imshow(g) We also use the function fft2 in Matlab to obtain directly the 2 – D DFT; fft2 function is the Fast Fourier Transform. In fact, the DFT and its inverse are obtained by using a FFT algorithm. And, the inverse of FFT is obtained by using the function ifft2. Hereafter, we would like to use the FFT.
  • 6. 5 2. Frequency domain smoothing filters We would like to show the basic steps for filtering in the frequency domain as the diagram below, Pre- processing Fourier transform Filter function H(u,v) Pre- processing Inverse Fourier transform f(x,y) Input image g(x,y) Enhanced image F(u,v) H(u,v)F(u,v) 2.1. Ideal low-pass filters (ILPF) With ILPF case, the filter function H (u, v) is defined as, 1 if D (u, v) ≤ D0 H (u, v) = 0 if D (u, v) ≥ D0 Where D (u, v) is the distance from any point (u, v) to the center (origin) of the Fourier transform and it is given by, D (u, v) = sqrt (u2 + v2 ) And D0 is a specified distance from the origin of the (centered) transform. We write a function to compute the ILPF, this function name is ilpf, function g = ilpf(f,D0) [M,N]=size(f); F=fft2(double(f)); u=0:(M-1); v=0:(N-1); idx=find(u>M/2); u(idx)=u(idx)-M;
  • 7. 6 idy=find(v>N/2); v(idy)=v(idy)-N; [V,U]=meshgrid(v,u); D=sqrt(U.^2+V.^2); H=double(D<=D0); G=H.*F; g=real(ifft2(double(G))); subplot(1,2,1); imshow(f); title('Input image'); subplot(1,2,2); imshow(g,[ ]); title('Enhanced image'); end We type the command, >> f = imread (‘Fig4.11(a).jpg’); >> g = ilpf (f, 30); It yields the images below, 2.2. Butterworth low-pass filter (BLPF) With the BLPF, the filter function H (u, v) is, ( ) ( )
  • 8. 7 Where n is the order. We write a function to compute the BLPF, this function name is blpf, function g = blpf(f,n,D0) [M,N]=size(f); F=fft2(double(f)); u=0:(M-1); v=0:(N-1); idx=find(u>M/2); u(idx)=u(idx)-M; idy=find(v>N/2); v(idy)=v(idy)-N; [V,U]=meshgrid(v,u); D=sqrt(U.^2+V.^2); H = 1./(1 + (D./D0).^(2*n)); G=H.*F; g=real(ifft2(double(G))); subplot(1,2,1); imshow(f); title('Input image'); subplot(1,2,2); imshow(g,[ ]); title('Enhanced image'); end We type the command, >> f = imread (‘Fig4.11(a).jpg’); >> g = blpf (f, 2, 30); It yields the images below,
  • 9. 8 2.3. Gaussian low-pass filter (GLPF) With the GLPF, the filter function H (u, v) is, ( ) ( ) ( ) We write a function to compute the BLPF, this function name is blpf, function g = glpf(f,D0) [M,N]=size(f); F=fft2(double(f)); u=0:(M-1); v=0:(N-1); idx=find(u>M/2); u(idx)=u(idx)-M; idy=find(v>N/2); v(idy)=v(idy)-N; [V,U]=meshgrid(v,u); D=sqrt(U.^2+V.^2); H = exp(-(D.^2)./(2*(D0^2))); G=H.*F; g=real(ifft2(double(G))); subplot(1,2,1); imshow(f); title('Input image'); subplot(1,2,2); imshow(g,[ ]); title('Enhanced image'); end We type the command, >> f = imread (‘Fig4.11(a).jpg’); >> g = glpf (f, 30); It yields the images below,
  • 10. 9 3. Sharpening frequency domain filters Image sharpening can be achieved in the frequency domain by a high-pass filtering process. The high- pass filter function, Hhp (u, v) is defined as, Hhp (u, v) = 1 – Hlp (u, v) 3.1. Ideal high-pass filters (IHPF) With the reason above, we can obtain the IHPF from the ILPF by changing the filter function H (u, v). The function to compute the IHPF is, function g = ihpf(f,D0) [M,N]=size(f); F=fft2(double(f)); u=0:(M-1); v=0:(N-1); idx=find(u>M/2); u(idx)=u(idx)-M; idy=find(v>N/2); v(idy)=v(idy)-N; [V,U]=meshgrid(v,u); D=sqrt(U.^2+V.^2); H=double(D<=D0); H=1-H; G=H.*F;
  • 11. 10 g=real(ifft2(double(G))); subplot(1,2,1); imshow(f); title('Input image'); subplot(1,2,2); imshow(g,[ ]); title('Enhanced image'); end We type the command, >> f = imread (‘Fig4.11(a).jpg’); >> g = ihpf (f, 15); It yields the images below, 3.2. Butterworth high-pass filters (BHPF) The filter function of the BHPF of order n and with cutoff frequency locus at distance D0 from the origin is given by, ( ) ( ) We change the filter function H (u,v) in the BLPF for obtaining the BHPF. Here is the BHPF function, function g = bhpf(f,n,D0) [M,N]=size(f); F=fft2(double(f)); u=0:(M-1); v=0:(N-1); idx=find(u>M/2);
  • 12. 11 u(idx)=u(idx)-M; idy=find(v>N/2); v(idy)=v(idy)-N; [V,U]=meshgrid(v,u); D=sqrt(U.^2+V.^2); H = 1./(1 + (D0./D).^(2*n)); G=H.*F; g=real(ifft2(double(G))); subplot(1,2,1); imshow(f); title('Input image'); subplot(1,2,2); imshow(g,[ ]); title('Enhanced image'); end We type the command, >> f = imread (‘Fig4.11(a).jpg’); >> g = bhpf (f, 2, 15); It yields the images below, 3.3. Gaussian high-pass filters (GHPF) The filter function of GHPF with cutoff frequency locus at a distance D0 from the origin is given by, ( ) ( ) We change the filter function H (u,v) in the GLPF for obtaining the BHPF. Here is the GHPF function, function g = ghpf(f,D0) [M,N]=size(f);
  • 13. 12 F=fft2(double(f)); u=0:(M-1); v=0:(N-1); idx=find(u>M/2); u(idx)=u(idx)-M; idy=find(v>N/2); v(idy)=v(idy)-N; [V,U]=meshgrid(v,u); D=sqrt(U.^2+V.^2); H = 1 - exp(-(D.^2)./(2*(D0^2))); G=H.*F; g=real(ifft2(double(G))); subplot(1,2,1); imshow(f); title('Input image'); subplot(1,2,2); imshow(g,[ ]); title('Enhanced image'); end We type the command, >> f = imread (‘Fig4.11(a).jpg’); >> g = bhpf (f, 15); It yields the images below,
  • 14. 13 4. Homomorphic filtering The Homomorphic filtering approach is summaried in the Figure below. Ln DFT H (u, v) Inverse DFT exp f(x, y) Input immage g(x, y) Enhanced image Homomorphic filtering approach for image enhancement In the Homomorphic filtering, the filter function H (u, v) is varied according to the special purpose. In the function below, we choose one, that is, ( ) ( ) ( ) Where, H and L are two parameters. Here is the Homomorphic filter function, function g = homo_filter(f,D0,gamaH,gamaL) [M,N]=size(f); u=0:(M-1); v=0:(N-1); idx=find(u>M/2); u(idx)=u(idx)-M; idy=find(v>N/2); v(idy)=v(idy)-N; [V,U]=meshgrid(v,u); D=sqrt(U.^2+V.^2); H = 1 - exp(-(D.^2)./(2*(D0^2))); % Gaussian high-pass filter H = (gamaH - gamaL)*H + gamaL;
  • 15. 14 z = log2(1+double(f)); % Log transfrom Z = fft2(z); S=H.*Z; s=real(ifft2(double(S))); g = 2.^s; subplot(1,2,1); imshow(f); title('Input image'); subplot(1,2,2); imshow(g,[ ]); title('Enhanced image'); end We type the command, >> f = imread (‘Fig.ex.jpg’); >> g = homo_filter(f,10,0.5,0.2); It yields the images below,
  • 16. 15 REFERENCES 1. Rafael C. Gonzalez,.; Woods, R. E., “Digital Image Processing“, Prentice Hall, 2002. 2. Rafael C. Gonzalez, Richard E. Woods, Steven L; Woods, R. E., “Digital Image Processing Using MATLAB“, Prentice Hall, 2005. 3. http://www.mathworks.com/ 4. http://www.imageprocessingplace.com/index.htm