MATLAB GRAPHICAL USER INTERFACE (GUI) FOR DIGITAL IMAGE IMPROVEMENT HASSAN BIN LEE. Tesis ini dikemukakan

MATLAB GRAPHICAL USER INTERFACE (GUI) FOR DIGITAL IMPROVEMENT HASSAN BIN LEE Tesis ini dikemukakan Fakulti Kejuruteraan, Universiti kepada Mal...
39 downloads 3 Views 512KB Size
MATLAB

GRAPHICAL

USER INTERFACE

(GUI) FOR DIGITAL

IMPROVEMENT

HASSAN BIN LEE

Tesis ini dikemukakan Fakulti Kejuruteraan,

Universiti

kepada Malaysia Sarawak

Sebagai memenuhi sebahagian daripada syarat Penganugerahan dengan Kepujian

Sarjana Muda Kejuruteraan

(Kejuruteraan

2003

1

Elektronik

dan Komputer)

IMAGE

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 difficulties I the encountered when supports

for they're opinions and

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 development. application

iv

Abstrak

Idea penampilan

asas untuk

pembikinan

sesuatu imej digital yang mungkin

yang tidak dikehendaki. kaedah

transformasi

asas pada peringkat

iaitu

kaedah-kaedah

geometri.

penambahan

dihasilkan

adalah

imej

bermakna menentukan

Dengan

langkah

pemprosessan

dan

kepada kaedah-kaedah

dalam

pemprosessan

untuk membangunkan

imej

perisian applikasi

grafik untuk pengguna bagi memudahkan

Keputusan

kepada

untuk

setiap imej

keluaran itu

yang Ini

imej keluaran yang terbaik adalan dibuat secara subjektif

dan

tertentu

pembangunan

permulaan

imej

imej

penapisan

sendiri.

tiada piawaian-piawaian tidak.

kualiti

memperbaiki

imej digital, terdapat tiga

kontras,

dan pemulihan

digital.

bergantung

kualiti

ini adalah berdasarkan

ataupun dengan kata lain pengantaramuka pembaikian

untuk

terganggu oleh hingar ataupun isyarat

manipulasi

telah digunakan

Perisian MATLAB

kerja-kerja

adalah

Bagi tujuan memperbaiki

digunakan

telah

yang

digital.

tesis ini

kepada

imej digital

untuk

applikasi lebih

pengendali

pemerhatian

menentukan perisian

sama ada imej

ini diharap

lagi kajian

banyak

yang kini semakin diperlukan

applikasi.

V

menjadi

itu baik

atau

sebagai satu

dan pembangunan

terhadap

dalam setiap pembangunan

TABLE OF CONTENTS

Page

Dedication

ii

Acknowledgment

111

Abstract

iv

Abstrak

V

Table of Contents

V1

List of Figures

XI

List of Tables

xiv

CHAPTER

1 INTRODUCTION

I

1.1 Background

1

1.2 Objectives

2

1.3 Thesis outline

3

CHAPTER

2 LITERATURE

4

REVIEW

4

2.1 Introduction to Digital Image 2.1.1 Image Digitization

5

2.1.2 Image Resolution

7

2.2 Introduction to Digital Image Processing 2.2.1 Application of Digital Image Processing

V1

9 11

2.3 Introduction to MATLAB 2.3.1 The MATLAB

13

System

14

2.4 Image Improvement

16

2.5 Image Enhancement

16

2.5.1 Gray-Level Transformations

18

2.5.1.1 Contrast Stretching

18

2.5.1.2 Gamma Correction

20

2.5.2 Histogram Processing

21

2.5.2.1 Histogram Equalization 2.5.3 Image Noise

24 25

2.5.3.1 Gaussian Noise

26

2.5.3.2 Rayleigh Noise

27

2.5.3.3 Erlang Noise

27

2.5.3.4 Exponential Noise

28

2.5.3.5 Uniform Noise

28

2.5.3.6 Impulse Noise

28

2.5.4 Basic of Spatial Filtering

29

2.5.4.1 Smoothing Spatial Filter

31

2.5.4.1.1 Gaussian Filter

31

2.5.4.1.2 Averaging Filter

33

2.5.4.1.3 Median Filter

34

2.5.4.2 Sharpening Spatial Filter 2.2.4.2.1 Unsharp Filter

35 35

36

2.6 Image Restoration 2.6.1 Weiner Filter

37

vii

2.6.2 Inverse Filter

37

2.7 Geometric Transformations

38

2.7.1 Image Rotation

39

2.7.2 Image Scaling

40

2.7.3 Gray Level Interpolation

40

CHAPTER

2.7.3.1 Nearest Neighbor Interpolation

41

2.7.3.2 Linear Interpolation

42

2.7.3.3 Bicubic Interpolation

43

3 DESIGN AND IMPLEMENTATION

44

3.1

Image Processing in MATLAB

44

3.2

What is the Image Processing Toolbox

44

3.3

Images in MATLAB

45

and the Image Processing Toolbox

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

3.8

3.9

Geometric Manipulation

64

3.7.1

Interpolation

64

3.7.2

Image Resizing

65

3.7.3

Image Cropping

66

3.7.4

Image Rotation

67

MATLAB

GUI Design

69

3.8.1 Creating GUIs with GUIDE

70

3.8.1.1 GUI Development Environment

70

3.8.1.2 The Implementation of a GUI

71

3.8.1.3 GUI Layout Tools

71

3.8.1.4 Programming GUI

72

GUI Implementation

Chapter 4 RESULTS

73

AND DISCUSSIONS

80

4.1 Intensity Adjustment

80

4.2 Image Filtering

82

4.3 Geometric Transformation

83

CHAPTER

5 RECOMMENDATION

AND CONCLUSION

87

5.1 Recommendation

87

5.2 Conclusion

89

REFERANCES

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

3.14

The flow chart of the image improvement process in the first GUI

3.15

MATLAB

3.16

The flow chart of the image improvement process in the second

72

GUI Layout Tools

GUI for the first part

75 76 77

GUI GUI for the second part

78

3.17

MATLAB

4.1

The result of the intensity adjustment

81

4.2

Histogram equalization of the image

82

4.3

The result of noise reduction

84

xii

4.4

The rescaled image result

85

4.5

The result of rotated image

86

xiii

LIST OF TABLES

Table

3.1

Page

Image conversion functions

xiv

54

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 began Propulsion (Pasadena, California) in Jet Laboratory 1964 the at space probe 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 diagnosis. in important medical element most

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

Processing of image data for storage, transmission, and representation

(ii)

for autonomous machine perception.

In this thesis, the attention will be focused on the digital image enhancement and restoration techniques. The principle improve of pictorial

information

application of this thesis project is to

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.

Objectives

1.2

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

included. transformation were also geometric

The implementation

improvement image the of

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

2.1

Introduction

REVIEW

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 image is (x, This type of position called continuous tone image. 131 y). coordinate

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 is impinges face 2D be that the the to actually sensor on of a physical signal consider ), and time (t). a function of many variables including depth (z), color (A.

4

Comm u

'/ýmlb,. ._ýýýýýý

Ai ammot»#a 1mm/imor ýýý rllý"

.

lowEstm=

ý:ý ý ýýrýý. ýý.

»..

Row

ýý.tr'ýýýýýý....

u.

ýý"z_"ýý®ýilriýAllýý ýC'=F': ý?ýý lýýýk'" 1"JUNN NEE

®1i"/!

M /itaý.

_... r_

-, mow 'Ik;.

! p'i//ý/ý///ý'ý'/ýýf //ý/ ////®/!

/

ýa u .

ýr : Yýýýý 1'. a//aý

/ r ý:

/////////////ýr /ý/ý

ýýU ' ý'

/.

ý a / uu

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 integer to the value. The process of representing the amplitude of the nearest rounded 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

in 2.2. is Figure process shown Converting from a continuous image f (x, y) to its digital representation I (i, j) The level). both (gray discretization the amplitude of spatial coordinates and require 2.3 is Figure discretization of spatial coordinates called process. of sampling process illustrates the sampling process.

5

Quantizer

Sampler

Sampled and Quantized Image

Sampled Image

Continuous Tone Image

Figure 2.2: Digitization process

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.

1

0,0

ºX

1

V Figure 2.3 Sampling Process.

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 into be divided two primary parts: can characteristics

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

image processing used by means of digital

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

processing because of continuing technologies.

improvements

form

of image

in sophisticated semiconductor

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 include for image display. Examples contrast and edge enhancement, or analysis pseudocoloring,

noise filtering,

sharpening and magnifying.

The enhancement

increase inherent information in data. It simply itself does the the content not process 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

9

by images degraded the of

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 nonimage 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 forms 131 image image techniques. two primary of synthesis are visualization of an

10

Suggest Documents