Você está na página 1de 24

MATLAB GRAPHICAL USER INTERFACE (GUI) FOR DIGITAL IMAGE

IMPROVEMENT
HASSAN BIN LEE
Tesis ini dikemukakan kepada
Fakulti Kejuruteraan, Universiti Malaysia Sarawak
Sebagai
memenuhi sebahagian
daripada
syarat
Penganugerahan Sarjana Muda Kejuruteraan
dengan Kepujian (Kejuruteraan Elektronik dan Komputer)
2003
1
To
my
beloved Family
11
Acknowledgment
First
of all,
I
would
like
to
dedicate
this
project
to
all my
family
members
especially my parents
for
their
supports, encouragement and
love during
the
period
of
this
study.
I
also would
like
to take this
opportunity
to
express my gratitude
to
my
supervisor,
Mr. Kismet Hong Ping for being
supportive and willing
to
sacrifice
his
precious
time
in
providing guidance and advice
to
make
this
project
in
success.
Special
thanks to
my colleagues and
Ms. Artini for
they're
opinions and
supports when
I
encountered
the
difficulties during
the
implementation
of
this
project.
Last but
not
least, I
wish
to
express my most appreciation
to the
Faculty
of
Engineering,
under
the
excellent
leadership
of
Associate Prof. Dr. Mohammad
Kadim
as a
Dean, for
allowing me
to
use all
kind
of resources available
in
the
laboratory.
111
Abstract
The idea
of
this thesis
is
to
improve
the
appearance quality of
the
degraded
digital image. For
the
improvement
purpose,
three
methods are used such as contract
manipulation,
image filtering
and geometric
transformation.
These
methods actually
based
on
the
basic
methods of
image
enhancement and restoration
in digital image
processing.
The MATLAB
software
is
used
to
develop
an application software or
GUI (Graphical User Interface)
that
enable
the
user
to
improve
an
image
easily.
The
quality of
the
output
image is
usually
depends
on
the
viewer
judgment. The
result
is
obtained subjectively and
there
are no specific standards
to
characterized
the
good
image. Therefore, this thesis
might
be
the
initial
step
for
more
detail
research on
the
digital image
processing where nowadays
it becomes
the
major part of any new
application
development.
iv
Abstrak
Idea
asas untuk pembikinan
tesis
ini
adalah untuk memperbaiki
kualiti
penampilan sesuatu
imej digital
yang mungkin
terganggu
oleh
hingar
ataupun
isyarat
yang
tidak
dikehendaki. Bagi
tujuan
memperbaiki
kualiti imej digital,
terdapat tiga
kaedah
yang
telah
digunakan iaitu
manipulasi
kontras,
penapisan
imej dan
transformasi
geometri.
kaedah-kaedah ini
adalah
berdasarkan kepada kaedah-kaedah
asas pada peringkat penambahan
dan
pemulihan
imej dalam
pemprosessan
imej
digital. Perisian MATLAB telah
digunakan
untuk membangunkan perisian applikasi
ataupun
dengan kata lain
pengantaramuka grafik untuk pengguna
bagi
memudahkan
kerja-kerja
pembaikian
imej digital. Keputusan
untuk setiap
imej keluaran
yang
dihasilkan
adalah
bergantung kepada
pemerhatian pengendali
itu
sendiri.
Ini
bermakna
menentukan
imej keluaran
yang
terbaik
adalan
dibuat
secara subjektif
dan
tiada
piawaian-piawaian
tertentu
untuk menentukan sama ada
imej itu baik
atau
tidak.
Dengan
pembangunan applikasi perisian
ini diharap
menjadi sebagai satu
langkah
permulaan
kepada lebih banyak lagi kajian dan
pembangunan
terhadap
pemprosessan
imej digital
yang
kini
semakin
diperlukan dalam
setiap pembangunan
applikasi.
V
TABLE OF CONTENTS
Dedication
Acknowledgment
Abstract
Abstrak
Table
of
Contents
List
of
Figures
List
of
Tables
CHAPTER 1 INTRODUCTION
1.1 Background
1.2 Objectives
1.3 Thesis
outline
CHAPTER 2 LITERATURE REVIEW
2.1 Introduction to
Digital Image
2.1.1 Image Digitization
2.1.2 Image Resolution
2.2 Introduction to
Digital Image Processing
2.2.1 Application
of
Digital Image Processing
Page
ii
111
iv
V
V1
XI
xiv
I
1
2
3
4
4
5
7
9
11
V1
2.3 Introduction
to MATLAB
2.3.1 The MATLAB System
2.4 Image Improvement
2.5 Image Enhancement
2.5.1 Gray-Level Transformations
2.5.1.1 Contrast Stretching
2.5.1.2 Gamma Correction
2.5.2 Histogram Processing
2.5.2.1 Histogram Equalization
2.5.3 Image Noise
2.5.3.1 Gaussian Noise
2.5.3.2 Rayleigh Noise
2.5.3.3 Erlang Noise
2.5.3.4 Exponential Noise
2.5.3.5 Uniform Noise
2.5.3.6 Impulse Noise
2.5.4 Basic
of
Spatial Filtering
2.5.4.1 Smoothing Spatial Filter
2.5.4.1.1 Gaussian Filter
2.5.4.1.2 Averaging Filter
2.5.4.1.3 Median Filter
2.5.4.2 Sharpening Spatial Filter
2.2.4.2.1 Unsharp Filter
2.6 Image Restoration
2.6.1 Weiner Filter
13
14
16
16
18
18
20
21
24
25
26
27
27
28
28
28
29
31
31
33
34
35
35
36
37
vii
2.6.2 Inverse Filter
2.7 Geometric Transformations
2.7.1 Image Rotation
2.7.2 Image Scaling
2.7.3 Gray Level Interpolation
2.7.3.1 Nearest Neighbor Interpolation
2.7.3.2 Linear Interpolation
2.7.3.3 Bicubic Interpolation
37
38
39
40
40
41
42
43
CHAPTER 3 DESIGN AND IMPLEMENTATION 44
3.1 Image Processing in MATLAB
3.2 What is
the
Image Processing Toolbox
3.3 Images in MATLAB
and
the
Image Processing Toolbox
44
44
45
3.3.1 Data Types 46
3.3.2 Reading, Writing, Displaying
and
Image Information 46
3.3.3 Image Types in The Toolbox 47
3.3.3.1 Converting Image to
Other Types 53
3.4 Image Histogram
and
Histogram Equalization 54
3.5 Contrast Manipulation
57
3.6 Image Filtering
58
3.6.1 Filtering
using
imfilter 58
3.6.2 Filtering
using
Predefined Filter Types 59
3.6.3 Filtering
using medfilt2
61
3.6.4 Filtering
using wiener2
62
viii
3.7 Geometric Manipulation
3.7.1 Interpolation
3.7.2 Image Resizing
3.7.3 Image Cropping
3.7.4 Image Rotation
3.8 MATLAB GUI Design
3.8.1 Creating GUIs
with
GUIDE
3.8.1.1 GUI Development Environment
3.8.1.2 The Implementation
of a
GUI
3.8.1.3 GUI Layout Tools
3.8.1.4 Programming GUI
3.9 GUI Implementation
Chapter 4 RESULTS AND DISCUSSIONS
4.1 Intensity Adjustment
4.2 Image Filtering
4.3 Geometric Transformation
CHAPTER 5 RECOMMENDATION AND CONCLUSION
5.1 Recommendation
5.2 Conclusion
REFERANCES
64
64
65
66
67
69
70
70
71
71
72
73
80
80
82
83
87
87
89
90
ix
BIBLIOGRAPHY
APPENDIX A
APPENDIX B
92
X
LIST OF FIGURES
Figure
Page
2.1 Digitization
of a continuous
image
5
2.2 Digitization
process 6
2.3 Sampling Process.
6
2.4 Spatial
resolutions 8
2.5 Gray level
resolutions
8
2.6 Image Enhancement
techniques 18
2.7 Contrast
stretching
transformation
function
19
2.8 Contrast
stretching
20
2.9 Gamma
correction
21
2.10 Image histogram 22
2.11 Four basic image
types
with
their
histogram 23
2.12 Histogram
equalization
25
2.13 An
example of
image
noise
26
2.14 Convolution
mask
30
2.15 2-D Gaussian distribution
with mean
(0,0)
and
u=1
32
2.16 Discrete
approximation
to
Gaussian function
with o =1.0
32
2.17 3x3 filter
mask
3X3
averaging
filter
often used
in
averaging
filter 33
2.18 3x3 Square
neighborhoods and
its
median value
34
2.19 Unsharp filtering
operator.
36
2.20 Geometric Transformations 38
X1
2.21 Scaling factor
of
2 40
2.22 Nearest Neighbor Interpolation 41
2.23 Linear Interpolation 42
3.1 An indexed image
called
tower
jpg 49
3.2 An intensity image
called
kinabalu jpg 50
3.3 Binary image 51
3.4 Image Histogram 55
3.5 Histogram Equalization 56
3.6 Contrast Manipulation
57
3.7 Filtering
an
image Using Predefined Filter Type for Gaussian 60
filter
3.8 Median filtering
62
3.9 Applied Weiner filter Using
wiener2
function 63
3.10 Image Resizing
66
3.11 Image Cropping
67
3.12 Image Rotation
69
3.13 MATLAB GUI Layout Tools
72
3.14 The flow
chart of
the
image improvement
process
in
the
first GUI 75
3.15 MATLAB GUI for
the
first
part
76
3.16 The flow
chart of
the
image improvement
process
in
the
second
77
GUI
3.17
MATLAB GUI for
the
second part
4.1 The
result of
the
intensity
adjustment
4.2 Histogram
equalization of
the
image
4.3 The
result of noise reduction
78
81
82
84
xii
4.4 The
rescaled
image
result
4.5 The
result of rotated
image
85
86
xiii
LIST OF TABLES
Table
Page
3.1 Image
conversion
functions
54
xiv
CHAPTER 1
INTRODUCTION
1.1 Background
The first
computer powerful enough
to
carry out meaningful
image
processing
tasks
appeared
in
the
early
1960s. The birth
of
digital image
processing
today
can
be
traced to the
availability of
those
machines and
the
onset of
the
space program
pursuing
by United States, National Aeronautics
and
Space Administration (NASA)
during
that
period.
Work
on using computer
techniques
for improving images from
space probe
began
at
the Jet Propulsion Laboratory (Pasadena, California) in 1964
when pictures of
the
moon
transmitted
by Ranger 7. [1)
In
parallel with space applications,
digital image
processing
techniques
began
in
the
late 1960s
and early
1970s to
be
used
in
medical
imaging,
remote earth
resources observations and astronomy.
In 1979, Computerized Tomography (CT)
invented by Sir Godfrey N. Hounsfield
and
Prof. Allan M. Cormack [11 becomes
the
most
important
element
in
medical
diagnosis.
Digital image
processing
is
a rapidly evolving
field
with growing applications
in
science and engineering.
Interest in digital image
processing methods stems
from
two-principle
application areas:
[2]
(i) Improvement
of pictorial
information for human interpretation,
and
I
(ii) Processing
of
image data for
storage,
transmission,
and representation
for
autonomous machine perception.
In
this thesis, the
attention will
be focused
on
the
digital image
enhancement
and restoration
techniques. The
principle application of
this thesis
project
is
to
improve
of pictorial
information in
an
image for human interpretation. MATLAB
version
6.1 Released 12.1
software
is
used
to
develop
an application
for image
enhancement and restoration.
1.2 Objectives
Basically, the
main
idea
of
this thesis
is
to
develop
an application software
using
MATLAB
to
improve
the
digital image. The
objectives of
this thesis
are as
follows:
i. Apply
several methods
that
can
be
used
to
improve
the
digital image
quality
ii. Analyze the
effect of each method when
it is
applied
to
an
image
iii. Compare
several methods according
to the
quality of
the
output
image
and
their
performances
iv. To improve
the
digital image
and
develop
an application software using
MATLAB
2
1.3 Thesis
outline
This
thesis
report
is divided into five
chapters.
Chapter 1 describes
the
background
of
the
digital image
processing.
In
addition,
this
chapter also stated
the
objectives of
the thesis.
Chapter 2
consists of
the
literature
review
that
is
relevant
to the thesis. It
includes
the
explanation of
the
digital image, image
processing and
MATLAB
that
are
important
elements
for
this thesis.
The
contrast manipulation,
image filtering
and
geometric
transformation
were also
included.
The implementation
of
the
image improvement
using
MATLAB
and an
application software
design
and
development
were
described in Chapter 3. The
functions
applied
in
this thesis
are obtained
directly from MATLAB
software.
At last
the
application software
development
was
illustrated.
Chapter 4
explains
the
results obtained after
testing the
application software
that
was
built.
Lastly, Chapter 5
consists of recommendations on
how
to
improve
this thesis
in
the
future
and
the
conclusion
in
regards
to this thesis.
3
CHAPTER 2
LITERATURE REVIEW
2.1 Introduction to Digital Image
A
natural
image begins
as a continuously varying array of shades and colors.
In
the
case of a photograph, shades vary
from light
to
dark
and colors vary
from
reds
through
yellows
to
blues. An image
considered
to
be
a
function
of
two
real variables,
for
example, a
(x,
y) with a as
the
amplitude
(e.
g.
brightness)
of
the
image
at
the
real
coordinate position
(x,
y).
This
type
of
image is
called continuous
tone
image. 131
On
the
other
hand,
a
digital image
a[m, n]
described in
a
2D discrete
space
is
derived from
an analog
image
a(x, y)
in
a
2D
continuous space
through
a sampling
process
that
is frequently
referred
to
as
digitization. The 2D
continuous
image
a(x y)
is divided into N
rows and
M
columns.
The intersection
of a row and a column
is
termed
a pixel.
The
value assigned
to the
integer
coordinates
[m
nj with
{m=0,1,2,...,
M-1}
and
{n=0,1,2,..., N-1} is
a[m, n].
In fact, in
most cases a
(x,
y), which
is
might
consider
to
be
the
physical signal
that
impinges
on
the
face
of a
2D
sensor
is
actually
a
function
of many variables
including depth (z),
color
(A. ),
and
time
(t).
4
u
Comm
Row
lowEstm=
.
rll"
1mm/imor
ammot#a
Ai

'/mlb,. . _
..
.
:
r.
u. .
tr'....
_... r_
1i"/! M/ita. 'Ik;. r
! p'i//////''/f
: Y
////////!
1'. a//a
//r:
a
/////////////r//
au.
/.
/uu
.
1"JUNNNEE -, mow
"z _"ilriAll U '
C'=F': ?
lk'"
'
Value
= a(x, y, z,
A,
z)
Figure 2.1 Digitization
of a continuous
image
The image
shown
in Figure 2.1 has been divided into N= 21
rows and
M=
20
columns.
The
value assigned
to
every pixel
is
the
average
brightness in
the
pixel
rounded
to the
nearest
integer
value.
The
process of representing
the
amplitude of
the
2D
signal at a given coordinate as an
integer
value with
L different
gray
levels is
usually referred
to
as amplitude quantization or simply quantization.
[41
2.1.1 Image Digitization
The digitization
process
is
used
to
form
a
digital image. This
process consists
of
two subprocesses called sampling and quantization process.
The digitization
process
is
shown
in Figure 2.2.
Converting from
a continuous
image f (x,
y)
to
its digital
representation
I (i, j)
require
discretization
of
both
spatial coordinates and
the
amplitude
(gray level). The
process of
discretization
of spatial coordinates
is
called sampling process.
Figure 2.3
illustrates the
sampling process.
5
Continuous
Tone Image
Sampled Image
Quantizer
Figure 2.2: Digitization
process
Sampled
and
Quantized
Image
Each dot in Figure 2.3
represents
the
physical
location
of each pixel on
the
continuous coordinate system where
the
measurements are made.
The
value of
the
image
at
that
location is further
quantized.
The
value of
L is
an
important
parameter
in
the
sampling process.
It determines
the
density
of sampling rate, which
determines
the
number of pixels
in
an
image.
0,0
Sampler
1
V
Figure 2.3 Sampling Process.
1
X
6
Quantization
process corresponds
to the
discretization
of
the
values of pixels.
The
number of quantization
levels
affects
the
number of
bits
needed
to
store
the
value of each pixel
[5]. For instance, if b bits
are used
to
represent
the
pixel gray
level,
then the total
number of gray
levels for
a an
intensity image is
given
by L=26,
means
that
for 8 bits
per pixel
(b=8),
the
gray
level is
equal
to 256 level.
2.1.2 Image Resolution
The
quality of
the
digital image is directly
related
to the
number of pixels and
lines,
along with
the
range of gray
level
values
in
the
image known
as
image
resolution.
Image
resolution also can
be defined
as
the
capability of
the
digital image
to
resolve
the
elements of
the
original scene
[3]. For digital image,
the
resolution
characteristics can
be divided into
two
primary parts:
a)
The
spatial resolution
Describe how
many pixels comprise a
digital image. For
more pixel
in
the
image,
the
greater
its
spatial resolution.
The
number of pixels
in
a
digital image depends
on
how finely
of
the
sample or
divides
the
image into discrete
pixels.
Figure 2.4
shows
the
examples of
the
spatial resolution
in digital image.
7
(a) (b)
Image
with
320
pixels x
240 lines Image
with
40
pixels x30
lines
Figure 2.4 Spatial
resolutions
b) Gray level
resolution
The
concept of gray
level
resolution addresses
how
accurately
the
digital
pixel's
gray
level
can represent
the
intensity
refer
to the
original
image. When the
numeric
range of a pixel's gray
level is increased,
so
it is
the
pixel's gray
level
resolution.
Figure 2.5
shows
the
examples of
the
gray
level
resolution
in digital image.
(a)
(b)
8 bits (256
gray
levels) image
2 bits (4
gray
levels) image
Figure 2.5 Gray level
resolutions
8
2.2 Introduction
to Digital Image Processing
Digital image
processing used
by
means of
digital
circuit, computer
processors and software
to
carry out an operation.
It is
a method of
image
processing
enabled
by
the
advent of
the
digital
computer.
Digital
techniques
provide precise
implementation
of
image
processing
function,
along with great
flexibility
and power
for
general-purpose
image
processing applications.
Digital image
processing
has become
a significantly
form
of
image
processing
because
of continuing
improvements in
sophisticated semiconductor
technologies.
This has led
to
computer
hardware
performance
increases
and
declining
cost.
[3J
Digital image
processing operations can
be broadly
grouped
into five
fundamental
classes:
a)
Image Enhancement
Image
enhancement
is
useful
in feature
extraction,
image
analysis, and visual
information display. The
goal
is
to
accentuate certain
image feature for
subsequent
analysis or
for image display. Examples include
contrast and edge enhancement,
pseudocoloring, noise
filtering,
sharpening and magnifying.
The
enhancement
process
itself does
not
increase
the
inherent information
content
in
the
data. It
simply
emphasizes
interactive
specified
image
characteristics.
[2]
b) Image Restoration
Image Restoration
refers
the technique to
removal or minimization of
known
degradations in
an
image. This includes deblurring
of
images degraded by
the
9
limitations
of a sensor or
its
environment, noise
filtering,
and correction of geometric
distortion
or non-linearity
due
to
sensors.
[21
c)
Image Analysis
Image
analysis operations
break
an
image into discrete
objects and
then
classify
that
object using some measurement process.
By
using
image
analysis,
quantitative measurements can
be
made
from
an
image
to
produce a
description
of
it.
Common image
analysis
techniques
include
extraction and
description
of scene and
overall
image feature,
automated measurements, and object classification.
131
d) Image Compression
Image
compression
deals
with
the technique
for
reducing
the
storage required
to
save an
image,
or
the
bandwidth
required
to transmit
it. It is
possible
to
be done
because
most
images inherently
contain
large
amounts of redundant
information.
Elimination
of
these
redundancies
is
the
goal of
image
compression
techniques.
[1
e)
Image Synthesis
Image Synthesis is
the technique to
create
images from
other
images
or non-
image data. These techniques
are used when a
desired image is
either physically or
impractical to
acquire, or
does
not exit
in
a physical
form
at all.
Reconstruction
and
visualization of an
image
are
two
primary
forms
of
image
synthesis
techniques.
131
10

Você também pode gostar