THE DEVELOPMENT OF A TRACKING
ALGORITHM FOR AMBULANCE DETECTION
USING SQUARING OF RGB AND HSV COLOR
PROCESSING TECHNIQUES
MOHAMMAD SYAWALUDIN SYAFIQ
BIN HASSAN
MASTER OF ENGINEERING (ELECTRONIC)
UNIVERSITI MALAYSIA PAHANG
UNIVERSITI MALAYSIA PAHANG
DECLARATION OF THESIS AND COPYRIGHT
Author’s Full Name : Mohammad Syawaludin Syafiq Bin Hassan
Date of Birth : 19 May 1990
Title : The Development of a Tracking Algorithm for
Ambulance Detection using Squaring of RGB and
HSV Color Processing Techniques
Academic Session : Semester II 2015/2016
I declare that this thesis is classified as:
CONFIDENTIAL (Contains confidential information under the
Official Secret Act 1972)
RESTRICTED (Contains restricted information as specified by the
organization where research was done)
OPEN ACCESS I agree that my thesis to be published as online open
access (Full text)
I acknowledge that Universiti Malaysia Pahang reserve the right as follows:
1. The Thesis is the Property of Universiti Malaysia Pahang.
2. The Library of Universiti Malaysia Pahang has the right to make copies for
the purpose of research only.
3. The Library has the right to make copies of the thesis for academic exchange.
Certified By:
(Student’s Signature) (Supervisor’s Signature)
DR. MOHD RAZALI
900519-11-5167 BIN DAUD
New IC / Passport Number Name of Supervisor
Date : 22 August 2016 Date : 22 August 2016
√
SUPERVISORS’ DECLARATION
We hereby declare that we have checked this thesis and in our opinion, this thesis is
adequate in terms of scope and quality for the award of the degree of Master of
Engineering (Electronic Engineering).
Signature :
Name of Supervisor : Dr. Mohd Razali Bin Daud
Position : Senior Lecturer
Date : 22 August 2016
Signature :
Name of Co-supervisor : Dr. Kamarul Hawari Bin Ghazali
Position : Associate Professor
Date : 22 August 2016
Signature :
Name of Co-supervisor : Nurul Wahidah Binti Arshad
Position : Lecturer
Date : 22 August 2016
STUDENT’S DECLARATION
I hereby declare that the work in this thesis is my own except for quotations and
summaries which have been duly acknowledged. The thesis has not been accepted for
any degree and is not concurrently submitted for award of other degree.
Signature :
Name : Mohammad Syawaludin Syafiq Bin Hassan
ID Number : MEL12006
Date : 22 August 2016
THE DEVELOPMENT OF A TRACKING ALGORITHM FOR AMBULANCE
DETECTION USING SQUARING OF RGB AND HSV COLOR PROCESSING
TECHNIQUES
MOHAMMAD SYAWALUDIN SYAFIQ BIN HASSAN
Thesis submitted in fulfillment of the requirements
for the award of the degree of
Master of Engineering (Electronic)
Faculty of Electrical & Electronics Engineering
UNIVERSITI MALAYSIA PAHANG
AUGUST 2016
vi
TABLE OF CONTENTS
Page
DECLARATION
TITLE PAGE i
DEDICATION ii
ACKNOWLEDGEMENTS iii iii
ABSTRACT iiv
ABSTRAK v
TABLE OF CONTENTS vi
LIST OF TABLES ixx
LIST OF FIGURES x
LIST OF SYMBOLS xivv
LIST OF ABBREVIATIONS xv
INTRODUCTION 1
1.1 Background of Study 1
1.2 Problem Statement 3
1.3 Motivation 4
1.4 Research Objectives 5
1.5 Scope of Research 5
1.6 Contribution 6
1.7 Thesis Organization 6
LITERATURE REVIEW 7
2.1 Introduction 7
2.2 Technology of Emergency Response 7
2.3 Ambulance Detection Algorithm 12
2.4 Traffic Monitoring Using CCTV and Image Processing 15
2.5 Summary 19
vii
RESEARCH METHODOLOGY 21
3.1 Introduction 21
3.2 Tracking Algorithm 22
3.3 Specific Method and Step in Tracking Algorithm 28
3.3.1 Data Acquisition 29 3.3.2 Data Collection 30 3.3.3 Convolution Image Blurring 36 3.3.4 Color Processing in Tracking Algorithm 40
3.3.5 Image Enhancement 48 3.3.6 Image Arithmetic Operations 51 3.3.7 Final Stage of Image Processing in Tracking Algorithm 56
3.3.8 Feature Extraction 58 3.3.9 Classification 60
3.4 Summary 62
RESULTS AND DISCUSSIONS 63
4.1 Introduction 63
4.2 Output from Tracking Algorithm 64
4.3 Analysis Proposed Tracking Algorithm 65
4.3.1 Analysis in Data Acquisition Part 66 4.3.2 Performance Evaluation of Pre-processing 72
4.3.3 Performance Evaluation of Major Part in Tracking Algorithm 77 4.3.4 Performance Evaluation of Feature Extraction and Classification
85
4.4 Summary 89
CONCLUSIONS AND RECOMMENDATIONS 91
5.1 Summary of Contributions 91
5.2 Limitations 93
5.3 Future Research Directions 94
REFERENCES 95
APPENDIX 99
A List of Publications 99
B Important Coding in the Tracking Algorithm 100
viii
C Pre-processing Analysis 103
D HSV Color Processing Analysis 111
E RGB Color Processing Analysis 121
F Region Boundaries Analysis 129
G Different Cases for Tracking Algorithm Analysis 132
H Structure Element (SE) Analysis 150
I Data Collection Process 159
ix
LIST OF TABLES
Table No. Title Page
1.1 Statistics new registered motor vehicles by type and state,
Malaysia, 2013
2
3.1 Important specification of Sony Handycam DCR-SR47 30
3.2 Four rules for image subtraction operation 53
3.3 Four rules for image multiplication operation 56
3.4 Sum of threshold pixel value of image 61
4.1 Difference between 45o degree and 30o degree of images 66
4.2 Analysis of result from the position of CCTV 70
4.3 Analysis of overall performance detection for tracking
algorithm and other study
84
4.4 Comparison between three color processing for tracking
algorithm of ambulance detection
85
4.5 Analysis of overall performance detection for tracking
algorithm 87
4.6 Analysis time taken for an ambulance to reach at the traffic
light for different distance and speed 89
x
LIST OF FIGURES
Figure No. Title Page
1.1 Statistics on total road accidents and motor vehicles involved,
Malaysia 2004-2013
2
2.1 View of the Intelligent Transportation System. Adapted from
“Road reservation for fast and safe emergency vehicle
response using ubiquitous sensor network” by (Yoo et al.
2010
8
2.2 The movement when emergency cases occur 10
2.3 View of proposed algorithm. Adapted from “Intelligent
ambulance detection system” by (Andronicus & Maheswaran
2015)
13
2.4 Ambulance with red & blue colored siren in prototype.
Adapted from “Smart control of traffic signal system using
image processing” by (Parthasarathi et al. 2015)
14
2.5 Overall process of vehicle detection system. Adapted from
“Vehicle detection using morphological image processing
technique” by (Ajmal & Hussain 2010)
16
2.6 Image from the simulation, (a) grayscale reference image, (b)
grayscale current image, (c) mask and (d) mask applied on
current image
16
2.7 Overall process Tomato Maturity Estimator. Adapted from
“Color grading in tomato maturity estimator using image
processing technique” by (Syahrir et al. 2009)
18
3.1 Flow chart of the tracking algorithm 22
3.2 MATLAB code for the process of converting video to frames
of image
24
3.3 MATLAB code for the pre-processing stage 24
3.4 MATLAB code for the HSV color processing 25
3.5 MATLAB code for the RGB color processing 26
3.6 MATLAB code for the HSV color processing 26
3.7 MATLAB code for the multiplication of two color processing 27
3.8 MATLAB code for the dilation technique 27
xi
3.9 Implementation of the SE for dilation technique 28
3.10 MATLAB code for the classification stage 28
3.11 UMP ambulance used for data collection 29
3.12 The view of data collection area, (a) the intersection of the
road and (b) the pedestrian bridge
31
3.13 View of data acquisition plan A, on the pedestrian bridge, at
the right side of the road
32
3.14 View of data acquisition plan B, on the pedestrian bridge, at
the left side of the road
33
3.15 View of data acquisition plan C, at the center of the road,
before the traffic light
34
3.16 View of data taken from Plan A 35
3.17 View of data taken from Plan B 35
3.18 View of data taken from Plan C 36
3.19 Example of applying the box linear filter: (a) original image
and (b) output image corresponding to box mask
38
3.20 Example of applying the Gaussian low pass filter: (a) original
image and (b) Gaussian LPF result
39
3.21 Example mask (a) Prewitt and (b) Sobel 39
3.22 Example of applying the Prewitt mask: (a) original image and
(b) Prewitt filter result
40
3.23 Example of applying the Sobel mask: (a) original image and
(b) Sobel filter result
40
3.24 Flow chart of major part in tracking algorithm 42
3.25 Combination of two color space 43
3.26 Schematic showing how pixels of an RGB color image are
formed from the corresponding pixels of three components
45
3.27 RGB color model 45
3.28 Hue-Saturation-Value-Hex cone 47
3.29 HSV color processing (a) filtering image, (b) HSV color
space image
48
xii
3.30 Sample of SE 49
3.31 Basic operation of dilation and erosion, (a) binary image A,
(b) structuring element B, (c) dilation A and (d) erosion A.
51
3.32 Image subtraction operations 53
3.33 Image addition operations 54
3.34 Image multiplication operations 55
3.35 Image Pre-processing and Image Processing (a) filtering
image, (b) HSV color space, (c) image segmentation and (d)
contour tracing image
57
3.36 Image Processing (a) original image (b) segmentation and
binarization RGB color space
58
3.37 Flowchart of the algorithm shown feature extraction part 59
3.38 Feature extraction, (a) original image (b) desired object in
final image
60
4.1 Overall detection using tracking algorithm (a) red component
from cylindrical-coordinate of primary color space, (b) red
component from additive color space, (c) image squaring of
red components from two color space, and (d) detected
emergency vehicle
65
4.2 Analysis the angle of video camera 67
4.3 Position of CCTV, (a) at the right side of the road, (b) at the
middle side of the road and (c) on the left side of the road
68
4.4 The position of CCTV in the real time at the intersection of
the road
71
4.5 Original Image 72
4.6 Different region of interest ambulance at the end of the stage
detection by using: (a) box linear filter, (b) Gaussian LPF, (c)
Prewitt filter and (d) Sobel horizontal edge-emphasizing filter
73
4.7 Original image for an ambulance far from Handycam 74
4.8 Different region of interest ambulance at the end of the stage
detection by using: (a) box linear filter, (b) Gaussian LPF, (c)
Prewitt filter and (d) Sobel horizontal edge-emphasizing filter
75
4.9 Detection percentage of ambulance using different filter for
convolution image blurring stage
76
xiii
4.10 Detection percentage of red/orange vehicles using different
filter for convolution image blurring stage.
77
4.11 RGB color line (a) original image (b) segmentation and
binarization additive color
78
4.12 HSV color line (a) original image, (b) segmentation and
binarization after cylindrical coordinate color
79
4.13 Image processing for feature extraction (a) red component
from HSV analysis, and (b) red component from RGB
analysis
80
4.14 View of ambulance detected using multiplication of two color
spaces
81
4.15 View of ambulance detected using multiplication of two color
spaces
81
4.16 View of no detection for red vehicles using multiplication of
two color spaces
82
4.17 View of no detection for red vehicles using multiplication of
two color spaces
82
4.18 View of ambulance not detected 83
4.19 Classification of ambulance detection 86
4.20 Proposed system block diagram 88
4.21 Sketched diagram for the proposed system. 88
xiv
LIST OF SYMBOLS
Pmax new pixel level
Pin input pixel level
fmin minimum value of desired range
fmax maximum value of desired range
Pnew,RGB new pixel color value
Pin,RGB input pixel color value
minRGB lowest pixel value
maxRGB highest pixel value
Pj(rj) histogram with intensity levels of image
n total number of pixels
nj total number of gray level pixels
rj gray level
A original binary image
B symmetric structuring element
A1 first input image
C constant
k clusters
xv
LIST OF ABBREVIATIONS
RGB Red, Green, Blue
YCbCr Luminance; Chroma:Blue; Chroma:Red
HSV Hue, Saturation, Value
HIS Hue, Intensity, Saturation
HSL Hue, Saturation, Lumination
CCTV Camera Closed-circuit Television
CMYK Cyan, magenta, yellow, key (black)
Eq. equation
et al. and others
i.e. that is
EMAS Expressway Monitoring and Advisory System
CHART Coordinated Highway Action Response Team
ADRS Accident Detection and Reporting System
ESP Emergency Service Provider
APID All Purpose Incident Detection
DES Double Exponential Smoothing
ATMS Advanced Traffic Management Systems
ARRS Traffic Accident Recording and Reporting System
MOG Mixture of Gaussian Model
GPRS General Packet Radio Service
GSM Global System for Mobile Communications
GPS Global Positioning System
RFID Radio Frequency Identification