Copyright is owned by the Author of the thesis. Permission is given for a copy to be downloaded by an individual for the purpose of research and private study only. The thesis may not be reproduced elsewhere without the permission of the Author. Finding Near Optimum Colour Classifiers : Genetic Algorithm-Assisted Fuzzy Colour Contrast Fusion using Variable Colour Depth A thesis presented to the Institute of Information and Mathematical Sciences in partial fulfillment of the requirements for the degree of Master of Science in Computer Science at Massey University, Albany, Auckland, New Zealand By Heesang Shin May 2009 c© Copyright 2009 by Heesang Shin iii iv Abstract This thesis presents a complete self-calibrating illumination intensity-invariantcolour classification system. We extend a novel fuzzy colour processing tech- nique called Fuzzy Colour Contrast Fusion (FCCF) by combining it with a Heuristic- assisted Genetic Algorithm (HAGA) for automatic fine-tuning of colour descriptors. Furthermore, we have improved FCCF’s efficiency by processing colour channels at varying colour depths in search for the optimal ones. In line with this, we intro- duce a reduced colour depth representation of a colour image while maintaining efficient colour sensitivity that suffices for accurate real-time colour-based object recognition. We call the algorithm Variable Colour Depth (VCD) and we propose a technique for building and searching a VCD look-up table (LUT). The first part of this work investigates the effects of applying fuzzy colour contrast rules to vary- ing colour depths as we extract the optimal rule combination for any given target colour exposed under changing illumination intensities. The second part introduces the HAGA-based parameter-optimisation for automatically constructing accurate colour classifiers. Our results show that for all cases, the VCD algorithm, combined with HAGA for parameter optimisation improve colour classification via a pie-slice colour classifier.For 6 different target colours, the hybrid algorithm was able to yield 17.63% higher overall accuracy as compared to the pure fuzzy approach. Fur- thermore, it was able to reduce LUT storage space by 78.06% as compared to the full-colour depth LUT. v vi Preface Some merits of this work has already been recognised, published and submit-ted. Lecture Notes in Computer Science, Springer-Verlag (accepted, to appear in 2009) : Variable Colour Depth Look-Up Table Based on Fuzzy Colour Processing, Heesang Shin and Napoleon H. Reyes, In Proceedings of ICONIP 2008 Memetic Computing Journal, Springer (submitted in 2009) : Finding Near Opti- mum Colour Classifiers : Genetic Algorithm-Assisted Fuzzy Colour Contrast Fusion using Variable Colour Depth, Heesang Shin and Napoleon H. Reyes vii viii Acknowledgements First , I would like to thank Dr. Napoleon Hamoay Reyes, without his insightand guidance I wouldn’t finish this thesis. That’s why I used pronoun we instead of I, he deserves it. I also equally thanks to my wife Kristen KyungEun, it wouldn’t appropriate to list just number of things to express her total support. Finally I dedicate this thesis to my elder son Daniel JinKyu, without him I wouldn’t able to return to study after long years in industry. ix x Contents Abstract v Preface vii Acknowledgements ix 1 Research Description 1 1.1 Overview of the Current State of Technology . . . . . . . . . . . . . 1 1.2 Research Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 1.2.1 General Objective . . . . . . . . . . . . . . . . . . . . . . . . 2 1.2.2 Specific Objectives . . . . . . . . . . . . . . . . . . . . . . . 3 1.3 Scope and Limitations of Research . . . . . . . . . . . . . . . . . . 3 1.4 Research Methodology . . . . . . . . . . . . . . . . . . . . . . . . . 4 1.5 Structure of the Thesis . . . . . . . . . . . . . . . . . . . . . . . . . 4 2 Theoretical Framework 5 2.1 Colour . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 2.2 Colour Space Models . . . . . . . . . . . . . . . . . . . . . . . . . . 7 2.2.1 CIE XYZ Colour Space and CIE 1931 Chromaticity Diagram 7 2.2.2 RGB Colour Model . . . . . . . . . . . . . . . . . . . . . . . 10 xi 2.2.3 CMY and CMYK Colour Models . . . . . . . . . . . . . . . 11 2.2.4 HSI Colour Model . . . . . . . . . . . . . . . . . . . . . . . 13 2.3 Colour Image Formation . . . . . . . . . . . . . . . . . . . . . . . . 15 2.3.1 Colour Separation Mechanism . . . . . . . . . . . . . . . . . 16 2.4 Colour Representation in Binary . . . . . . . . . . . . . . . . . . . . 18 2.4.1 Colour Depth . . . . . . . . . . . . . . . . . . . . . . . . . . 18 2.5 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 3 Review of Related Literature 21 3.1 Colour Segmentation . . . . . . . . . . . . . . . . . . . . . . . . . . 21 3.1.1 Indexing Via Color Histograms . . . . . . . . . . . . . . . . 21 3.1.2 A Robust and Fast Color-Extracting using a Look up Table 23 3.1.3 Color recognition . . . . . . . . . . . . . . . . . . . . . . . . 23 3.1.4 Real-time, adaptive color-based robot vision . . . . . . . . . 24 3.1.5 A Fast Algorithm for Color Image Segmentation . . . . . . . 25 3.1.6 Towards a calibration-free robot: The ACT algorithm for au- tomatic online color training . . . . . . . . . . . . . . . . . . 26 3.1.7 Automatic On-Line Color Calibration using Class-Relative Color Spaces . . . . . . . . . . . . . . . . . . . . . . . . . . 28 3.1.8 Adaptive recognition of color-coded objects in indoor and out- door environments . . . . . . . . . . . . . . . . . . . . . . . 29 3.1.9 Mean-shift-based color tracking in illuminance change . . . . 30 3.1.10 Robust color classification using fuzzy rule-based Particle Swarm Optimization . . . . . . . . . . . . . . . . . . . . . . . . . . 32 3.2 Fuzzy Logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 xii 3.2.1 Knowledge-Based Fuzzy Color Processing . . . . . . . . . . . 33 3.3 Fuzzy Colour Contrast Fusion (FCCF) . . . . . . . . . . . . . . . . 35 3.3.1 Dynamic Colour Object Recognition Using Fuzzy Logic . . . 35 3.3.2 Identifying Colour Objects with Fuzzy Colour Contrast Fusion 40 3.3.3 Hybrid Fuzzy Colour Processing and Learning . . . . . . . . 43 3.4 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 4 Central Thesis 49 4.1 Variable Colour Depth . . . . . . . . . . . . . . . . . . . . . . . . . 49 4.1.1 Look-up Table (LUT) . . . . . . . . . . . . . . . . . . . . . 58 4.1.2 LUT Building Algorithm . . . . . . . . . . . . . . . . . . . . 61 4.1.3 LUT Query Algorithm . . . . . . . . . . . . . . . . . . . . . 61 4.1.4 General Variable Colour Depth - FCCF System Architecture 62 4.2 Fuzzy-Genetic Colour Classifier Search . . . . . . . . . . . . . . . . 63 4.2.1 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 4.2.2 General Architecture . . . . . . . . . . . . . . . . . . . . . . 66 4.2.3 Chromosome Design . . . . . . . . . . . . . . . . . . . . . . 66 4.2.4 Fitness Function . . . . . . . . . . . . . . . . . . . . . . . . 67 4.3 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 5 Experiments and Analysis 69 5.1 Test Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 5.1.1 Assessment Method . . . . . . . . . . . . . . . . . . . . . . . 69 5.1.2 Reference Result . . . . . . . . . . . . . . . . . . . . . . . . 70 5.2 Variable Colour Depth with CCRE . . . . . . . . . . . . . . . . . . 70 xiii 5.2.1 Search Strategy . . . . . . . . . . . . . . . . . . . . . . . . . 71 5.2.2 Colour Classification Results of Full 24-bit Colour Depth vs. Variable Colour Depth . . . . . . . . . . . . . . . . . . . . . 71 5.2.3 Colour Contrast Rules and Scores . . . . . . . . . . . . . . . 72 5.2.4 Colour Contrast Rule Clustering . . . . . . . . . . . . . . . . 73 5.2.5 Colour Pixel Clustering . . . . . . . . . . . . . . . . . . . . . 74 5.2.6 Reductions in Memory Usage . . . . . . . . . . . . . . . . . 83 5.2.7 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 5.3 Fuzzy-Genetic Colour Calibration . . . . . . . . . . . . . . . . . . . 83 5.3.1 Fuzzy-Genetic Colour Calibration Parameters and Scores . . 86 5.3.2 Colour Contrast Rule Component Distribution . . . . . . . . 86 5.3.3 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 5.4 Discussion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 6 Conclusions 99 6.1 Suggestions for Future Work . . . . . . . . . . . . . . . . . . . . . . 100 Bibliography 101 Appendices 105 A Proposed System : FCCF Suite 105 A.1 Licences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 A.2 Software Integration . . . . . . . . . . . . . . . . . . . . . . . . . . 106 A.2.1 Qt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 A.2.2 OpenCV . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 A.2.3 QextSerialPort . . . . . . . . . . . . . . . . . . . . . . . . . 106 xiv A.2.4 TinyXML . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 A.2.5 GAlib . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 A.3 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 A.3.1 FCCF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 A.3.2 Cross-Platform Compatibility . . . . . . . . . . . . . . . . . 108 A.3.3 Video Capture . . . . . . . . . . . . . . . . . . . . . . . . . 109 A.3.4 Real-Time Object Tracking . . . . . . . . . . . . . . . . . . 109 A.3.5 GUI System . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 A.3.6 Robot Control . . . . . . . . . . . . . . . . . . . . . . . . . . 109 A.4 Test-Bed Hardware Specifications . . . . . . . . . . . . . . . . . . . 110 xv List of Tables 1 Quality Criteria For Good And Poor Welding Spots. From Knowledge- Based Fuzzy Color Processing, 2004 . . . . . . . . . . . . . . . . . . 34 2 Colour Descriptors for the Target Colours [1]. . . . . . . . . . . . . 42 3 Colour Contrast Rules for Each rg-chromaticity, YUV and, HSI Colour Spaces [1]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 4 False positive and true positive rates for the Colour Contrast Fusion Algorithm in rg-Chromaticity, YUV, and HSI Colour Spaces [1]. . . 42 5 Sample Variable Colour Depth Representations of the Normalised Colour Component Values 0.8 Red, 0.5 Green, and 1.0 Blue . . . . 50 6 Comparisons of Colour Classification Result between Indexed and VCD LUT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 7 Colour Classification Definition . . . . . . . . . . . . . . . . . . . . 70 8 Colour Classification Results of Full 24-bit Colour Depth vs. Variable Colour Depth . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 9 Colour Contrast Rule Distribution . . . . . . . . . . . . . . . . . . . 73 10 Fuzzy-Genetic Colour Calibration Experiment Configuration . . . . 91 11 Fuzzy-Genetic Colour Calibration Result for Yellow . . . . . . . . . 92 12 Fuzzy-Genetic Colour Calibration Result for Green . . . . . . . . . 93 13 Fuzzy-Genetic Colour Calibration Result for Pink . . . . . . . . . . 94 xvi 14 Fuzzy-Genetic Colour Calibration Result for Purple . . . . . . . . . 95 15 Fuzzy-Genetic Colour Calibration Result for Violet . . . . . . . . . 96 16 Fuzzy-Genetic Colour Calibration Result for Light Blue . . . . . . . 97 17 Colour Contrast Rule Component Distribution . . . . . . . . . . . . 98 18 Colour Pixel Distribution Changes after FCCF Applied in 6 Target Colours . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 19 Colour Classification and Contrast Angle Difference Between Fuzzy- Genetic Optimised Solution and Manual Calibrated Solution (size difference represents the angle difference relative to the base) . . . . 98 xvii List of Figures 1 Electromagnetic spectrum with Light Highlighted Picture created by Philip Ronan from Wikipedia . . . . . . . . . . . . . . . . . . . . . 6 2 Leaf Reflects Green Wavelength on The Surface to be Perceived . . 7 3 Schematic Diagram of the Human Eye and Cross Section View of Retina. Schematic created by Rhcastilhos from Wikipedia . . . . . . 8 4 An Optical Illusion. Square A is Exactly the Same Shade of Grey as Square B. Picture created by Adrian Pingstone, based on the original created by Edward H. Adelson [2] . . . . . . . . . . . . . . . . . . . 9 5 Simplified Human Cone Response Curve and Corresponding CIE XYZ Colour Matching Function . . . . . . . . . . . . . . . . . . . . 10 6 The CIE 1931 Colour Space Chromaticity Diagram. Picture created by Sakurambo from Wikipedia, based on the original created by CIE [3] 11 7 Schematic of the RGB Colour Cube . . . . . . . . . . . . . . . . . . 12 8 Flatten Schematic of the RGB Colour Cube . . . . . . . . . . . . . 13 9 The HSI-Colour Space . . . . . . . . . . . . . . . . . . . . . . . . . 14 10 A Transistor-Level Schematic of A Three-Pixel, Photodiode-Based Active Pixel Sensor. Diagram created by Gargan from Wikipedia . . 16 xviii 11 A Philips Type Trichroic Beam Splitter Prism Schematic, With a Different Colour Separation Order Than the Assembly Shown in the Photo. The Red Beam Undergoes Total Internal Reflection at the Air Gap, While the Other Reflections are Dichroic. Diagram created by Gargan from Wikipedia . . . . . . . . . . . . . . . . . . . . . . . 17 12 The Bayer Arrangement of Colour Filters on Image Sensor Array. Diagram created by Cburnett from Wikipedia . . . . . . . . . . . . . 18 13 Profile/Cross-Section of Bayer Filter Layered Sensor. Diagram cre- ated by Cburnett from Wikipedia . . . . . . . . . . . . . . . . . . . . 18 14 Two-Layer Pyramid Structure for Each Colour Component [4]. . . . 25 15 Block Diagram of the Colour Classification System [5]. . . . . . . . 28 16 Captured Panoramic Images with PID Controller under Four Light Conditions [6]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 17 Plots of YUV Colour Distribution Indoors [6]. . . . . . . . . . . . . 31 18 Plots of YUV Colour Distribution in Outdoor Environment [6]. . . 31 19 Adjusting RGB Colour Value by F-number [7]. . . . . . . . . . . . . 32 20 The HSL color Space Mapped to a Sphere, with Corner Cut-Away Shown. Figure created by SharkD from Wikipedia . . . . . . . . . . 33 21 The Demension H [8]. . . . . . . . . . . . . . . . . . . . . . . . . . . 33 22 Dimensions L and S [8]. . . . . . . . . . . . . . . . . . . . . . . . . 34 23 Regions of Interest of a Resistance Spot Welding Joint [9]. . . . . . 35 24 Fuzzy Set, Defined Over the HS-Colour Space [9]. . . . . . . . . . . 35 25 Colour Contrast and Classification System Architecture [10]. . . . . 36 26 rg-Chromaticity Colour Space with Origin Shift Position [10]. . . . 37 27 Pie-Slice Colour Decision Region in Modified rg-Chromaticity Colour Space [10]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 xix 28 Colour Contrast Enhance Operator (Sigmoid / Logistic Function) [10]. 39 29 Colour Contrast Degrade Operator (Logit Function) [10]. . . . . . . 40 30 Test Image with Pink Colour Patches in the Middle [10]. . . . . . . 40 31 Colour Classified Image. True Positive Pixels are in Light Blue, False Positive Pixels are in Blue Colours. . . . . . . . . . . . . . . . . . . 41 32 Results of Applying Colour Contrast Fusion in rg-Chromaticity, YUV, and HSI Colour Spaces [1]. . . . . . . . . . . . . . . . . . . . . . . . 43 33 The MPCL Algorithm [11]. . . . . . . . . . . . . . . . . . . . . . . 44 34 Extracted Object Colour Pixels From Two Consecutive Frames and Corresponding Colour Classification Variable Changes [11]. . . . . . 44 35 Normalised Input Values from Various Colour Depth . . . . . . . . 51 36 Enlarged Section of Normalised Input Values from Various Colour Depth Input Values from 1/8 to 2/8 . . . . . . . . . . . . . . . . . . 52 37 Examples of Colour Depth Reduction; (a) Original 24-bit RGB Im- age; (b) Reduced 15-bit RGB Image from (a); (c) 8-bit Gray-Scale Image from (a); (d) 4-bit Gray-Scale Image from (c). . . . . . . . . 53 38 Examples of Colour Depth Reduction; (a) Original 24-bit RGB Im- age, 55,880 Colours were Used; (b) Areas Where Colour Differences are Visible; (c) 16-bit RGB Image, 4,391 Colours were Used; (d) 15-bit RGB Image 2,814 Colours were Used. . . . . . . . . . . . . . 54 39 Comparisons of Colour Contrast Enhancement (1X Mode) Results Using Various Colour Depth Representations. . . . . . . . . . . . . 55 40 Comparisons of Colour Contrast Enhancement (2X Mode) Results Using Various Colour Depth Representations. . . . . . . . . . . . . 55 41 Comparisons of Colour Contrast Enhancement (3X Mode) Results Using Various Colour Depth Representations. . . . . . . . . . . . . 55 xx 42 Comparisons of Colour Contrast Degradation (1X Mode) Results Us- ing Various Colour Depth Representations. . . . . . . . . . . . . . . 56 43 Comparisons of Colour Contrast Degradation (2X Mode) Results Us- ing Various Colour Depth Representations. . . . . . . . . . . . . . . 56 44 Comparisons of Colour Contrast Degradation (3X Mode) Results Us- ing Various Colour Depth Representations. . . . . . . . . . . . . . . 56 45 Examples of Normalised Outputs Produced by the Lower Colour Component Depths. . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 46 RGB Colour Space in Variable Colour Depth of 3-8-8. . . . . . . . . 58 47 Comparisons between Standard Indexed LUT and VCD LUT. . . . 59 48 Shades of Colour between Blue and Pink. . . . . . . . . . . . . . . . 61 49 Variable Colour Depth Look-Up Table Construction Architecture . 63 50 Variable Colour Depth Look-Up Table for Real-Time Processing . . 64 51 The Shaded Pie-Slice, Covered by Arc L Represents The Area of Interest. Due to the Discretisation of the Angles, the Area of Interest Could Only be Approximated by a Smaller Pie-Slice, Covered by Angle θ. The Dotted Lines Indicate the Discretisation of Angles. . . 65 52 Fuzzy-Genetic Colour Classifier Search Architecture . . . . . . . . . 66 53 Chromosome Design . . . . . . . . . . . . . . . . . . . . . . . . . . 67 54 Mapping of all the Best Colour Contrast Rule Combinations for all Colour Depth Values and for each Target Colour . . . . . . . . . . . 74 55 Mapping of the Best Colour Contrast Rule Combinations for the Optimal Colour Depths for each Target Colour. Positive Number In- dicates Contrast Enhancement and Level of Contrast Application; 0 for No Operation, while a Negative Number Denotes Contrast Degra- dation. * n Indicates Number of Occurrences. . . . . . . . . . . . . 75 xxi 56 Colour Pixel Clustering on rg-Hue / rg-Saturation Chart for Light Blue Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 57 Colour Pixel Clustering on rg-Hue / rg-Saturation Chart for Light Blue Objects with FCCF . . . . . . . . . . . . . . . . . . . . . . . . 76 58 Colour Pixel Clustering on rg-Hue / rg-Saturation Chart for Yellow Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 59 Enlarged Colour Pixel Clustering on rg-Hue / rg-Saturation Chart for Yellow Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 60 Colour Pixel Clustering on rg-Hue / rg-Saturation Chart for Green Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 61 Enlarged Colour Pixel Clustering on rg-Hue / rg-Saturation Chart for Green Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 62 Colour Pixel Clustering on rg-Hue / rg-Saturation Chart for Pink Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 63 Enlarged Colour Pixel Clustering on rg-Hue / rg-Saturation Chart for Pink Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 64 Colour Pixel Clustering on rg-Hue / rg-Saturation Chart for Purple Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 65 Enlarged Colour Pixel Clustering on rg-Hue / rg-Saturation Chart for Purple Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 66 Colour Pixel Clustering on rg-Hue / rg-Saturation Chart for Violet Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 67 Enlarged Colour Pixel Clustering on rg-Hue / rg-Saturation Chart for Violet Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 68 Colour Pixel Clustering on rg-Hue / rg-Saturation Chart for Light Blue Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 xxii 69 Enlarged Colour Pixel Clustering on rg-Hue / rg-Saturation Chart for Light Blue Objects . . . . . . . . . . . . . . . . . . . . . . . . . 82 70 Contrast Rule Component Distribution for Yellow . . . . . . . . . . 87 71 Contrast Rule Component Distribution for Green . . . . . . . . . . 87 72 Contrast Rule Component Distribution for Pink . . . . . . . . . . . 88 73 Contrast Rule Component Distribution for Purple . . . . . . . . . . 88 74 Contrast Rule Component Distribution for Violet . . . . . . . . . . 89 75 Contrast Rule Component Distribution for Light Blue . . . . . . . . 89 76 A Screen-Shot of the Proposed System. . . . . . . . . . . . . . . . . 110 xxiii List of Algorithms 1 The Adaptive Colour-Based Robot Vision Algorithm [12]. . . . . . . 24 2 Look-Up Table Building Algorithm . . . . . . . . . . . . . . . . . . . 41 3 CCRE(image, targetbounds), Scoring Formula [11]. . . . . . . . . . . 45 4 Variable Colour Depth LUT Build Algorithm . . . . . . . . . . . . . 62 5 Variable Colour Depth LUT Query Algorithm . . . . . . . . . . . . . 63 xxiv