Study of RGB Color Classification Using Fuzzy Logic

4 downloads 2034 Views 350KB Size Report
focused. The RGB color model combines Red, Green, and. Blue light in various ... Below is the Pseudo code to collect data from LDR. Delay of 50ms is ..... color.html. [3] http://en.wikipedia.org/wiki/RGB_color_model#cite_ref-. RWGHunt_2-1.
ETERD’10 Proceeding 2010 P j

Study of RGB Color Classification Using Fuzzy Logic Mohd Alif Syami Bin Azmi1, Nazrul Bin Mazli1, Yusman Yusof2, Mohd Fadzil Hj Abu Hassan2 1

Industrial Automation and Robotics Technology, Industrial Automation Section, Universiti Kuala Lumpur Malaysia France Institute, Section 14 Jalan Teras Jernang, 43650 Bandar Baru Bangi, Selangor. Tel: +603 8926 2022 Fax: +603 8925 8845 Email: [email protected], [email protected] 2

Industrial Automation Section Universiti Kuala Lumpur, Malaysia France Institute 43650 Bandar Baru Bangi, Selangor. Tel: +603 8926 2022 Fax: +603 8925 8845 Email: [email protected], [email protected]

Abstract Color has been a great help in identifying objects for many years. Color is the byproduct of the spectrum of light, as it is reflected or absorbed, as received by the human eye and processed by the human brain. In day to day practice, we will most likely use three models: HSV, CMYK and RGB. In this project, the RGB model will be focused. The RGB color model combines Red, Green, and Blue light in various ways to reproduce a broad array of colors. The RGB color of an object will be classified by using Fuzzy logic according to the data given by the analog sensor. This project aims in providing a better understanding on applying Fuzzy Logic in solving real life application for engineering technology students. Experiments will be conducted and the results will be used to demonstrate the color classification using Fuzzy Logic.

Key Words:

Fuzzy Logic, RGB color sensing,

Sensor.

1. Introduction Color has been a great help in identifying objects for many years. The process of color classification involves extraction of useful information concerning the spectral properties of object surfaces and discovering the best match from a set of known descriptions or class models to implement the recognition task [1]. Furthermore, most manufacturers prefer color classification systems that provide repeatable and reliable operation, as opposed to human inspection, which has a high margin of error due

to distraction, illness and other factors that increase the rate of failure during prolonged working hours. To overcome such difficulties, a RGB color classification system is introduced. This system is widely used in the industrial manufacturing and robotics, as it can reduce dependency on manpower and hence increase production.

2. Primary Colors Colors are actually light waves. Photographs, magazines and other objects of nature such as an orange; create color by subtracting or absorbing certain wavelengths of color while reflecting other wavelengths back to the viewer. This phenomenon is called subtractive color [2]. When light from the sun hits an object such as an orange, it absorbs all the colors except for orange. A white object refracted all colors. Therefore, white is really all the colors of the spectrum. Whereas something appears black to us because the all colors are absorbed and nothing is refracted. The color spectrum is made up of varying frequencies and wavelengths. Each color has its own designated space within the spectrum. The choice of primary colors is related to the physiology of the human eye. If the visible portion of the light spectrum is divided into thirds, the predominant colors are Red, Green and Blue. The RGB color model is an additive color model in which red, green, and blue light are added together in various ways to reproduce a broad array of colors. The main purpose of the RGB color model is for the sensing, representation, and display of images in electronic systems, such as televisions and computers [3].

1/1

ETERD’10 Proceeding 2010 P j The initial LEDs’ voltage readings taken before doing the experiment are: Red LED = 4.25V Green LED = 4.28V Blue LED = 4.23V

Picture taken from journal of computers, vol. 4, no. 7, July 2009

Figure 1: Pyramid of color Additive color mixing occurs when two or three beams of differently color light combine. It has been found that mixing just three additive primary colors; Red, Green and Blue, can produce the majority of colors. In general, a color can be described by certain quantities, called the tri-stimulus values, r for the red component, g for the green component, and b for the blue component [4], as follows: Color = r + g + b

3. System Overview A low cost sensor, Light-Dependent Resistors (LDR) is used to determine the lux levels reflected from an object. The sensor is basically a resistor that changes its resistive value (in ohms Ω) depending on how much light is shining onto the squiggly surface. Three RGB color LEDs will be used and object whose color is required to be detected should be perpendicularly placed in front of the system, hence the light rays reflected from the object will fall on the single LDR. The LEDs will be triggered in sequence for a short time.

Below is the Pseudo code to collect data from LDR. Delay of 50ms is needed to make sure the amount of light from the LED is at acceptable point to be captured by LDR. Turn on red LED delay 50ms record sensor reading R turn off red LED Turn on green LED delay 50ms record sensor reading G turn off green LED Turn on blue LED delay 50ms record sensor reading B turn off blue LED

A fuzzy logic inference engine is highly important in this color classification system. The MATLAB Fuzzy Logic Toolbox is used in this study as the centerpiece of the system in classifying colors and to display the results. The microcontroller will read the data from the color sensor and transfer into PC based MATLAB to classify the color with various brightness levels into three color classes: Red, Green, and Blue (RGB) colors and the decision making process will be based on Fuzzy Logic. Figure 3 shows the system setup.

Figure 3: Fuzzy Logic Color classification system Figure 2: Color sensor design The 8-bit AVR Butterfly microcontroller board is used as the preprocessor to capture data. One of the onboard 8-bit analog inputs is connected to the LDR and used to convert the sensor voltage outputs to digital form. Three separate discrete outputs are used to trigger the RGB LEDs by sequence and the converted digital sensor signals are transferred to PC via serial communication.

4. Fuzzy Logic Inference Engine A fuzzy logic inference engine, build upon fuzzy set theory will be developed to classify the color based on the sensor inputs. These inputs, operational laws and outputs will be expressed inside the engine in linguistic terms instead of the traditionally used mathematical equations. Figure 4 shows the block diagram of the inference engine for the used in color classification.

2/2

ETERD’10 Proceeding 2010 P j Table 1: Fuzzy Logic rules

RULE BASE

FUZZIFICATION

DECISION MAKING

R G B

DEFUZZIFICATION

Red or Green or Blue

Figure 4: Block diagram of the system

5. Fuzzification Fuzzification is the process of mapping crisp inputs to fuzzy membership functions. In fuzzy logic, it is important to distinguish not only which membership functions a variable belong to, but also the relative degree to which it is a member. Figure 5 shows the input crisp variable for the color sensor. In Figure 5, the fuzzy

membership function spans from a range of values and is overlapped. Three set of membership values are defined for the sensor inputs for the Red, Green and Blue colors: LOW, MEDIUM, and HIGH.

 

7. Defuzzification The defuzzification, calculation of the crisp output is where the output is generated based on the inputs and the rule base. In this case, the output is the color indicator of itself i.e Red or Green or Blue as shown in Figure 5. In this system, we are using Sugeno inference. It is a fuzzy set with a membership function that is unity at a single particular point on the universe of discourse and zero everywhere else [5]. Table 2: The output range to classify color

 

Figure 5: RGB color input membership functions

6. Inference Rule Definition The fuzzy rules specify the relationship between the input fuzzy membership sets and the output fuzzy membership values. It is in these rules; one builds the intuition of the controller. Table 1 shows the 15 rules used for the color classification:

Because the fuzzy controller is modular, we begin by testing each of the modules separately. Fuzzification parameters are adjusted so that the sensor data are captured in the set of values contained in the fuzzy input variables. The rules are adjusted and modified so that fuzzy output variables properly describe what should be the result. Lastly, the defuzzification parameters are tuned in order to produce the correct and consistent crisp output.

8. Experimental Result and Discussion

3/3

ETERD’10 Proceeding 2010 P j There are 18 levels of brightness sample color were tested for each colors shown in Figure 6.

l 31/8 31/7 31/6 31/5 31/4 31/3 31/2 31/1 31/01 31/02 31/03 31/04 31/05 31/06 31/07 31/08 31/09 31/010

Code

Table 3 to 5 shows the output results of Fuzzy System. Overall the system is able to classify the color with certain brightness level. But when the color is too dark and to bright the fuzzy controller is not able to produce a correct output. In order to overcome this problem, the result will be further analyzed and the fuzzy system will be tune to detect these colors. Table 3: Testing result on Red surface for different brightness level Leve l

7/8 7/7 7/6 7/5 7/4 7/3 7/2 7/1 7/01 7/02 7/03 7/04 7/05 7/06 7/07 7/08 7/09 7/01 0

1 2 3 4 5 6 7 8 9 10 11 12 14 15 16 17 18 19

RED Reading Vol Valu t e 3.77 238 3.87 246 4.03 255 4.14 261 4.16 263 4.15 263 4.18 264 4.15 263 4.23 267 4.23 267 X X X X X X X X -

GREEN Reading Vol Valu t e 2.45 154 1.90 119 2.44 154 2.13 133 2.19 137 2.35 148 2.52 158 2.43 153 3.00 189 2.85 179 X X X X X X X X -

BLUE Reading Vol Valu t e 2.89 182 2.68 169 2.97 187 2.50 157 2.66 167 2.06 128 2.63 166 2.60 164 3.06 193 3.18 201 X X X X X X X X -

RESULT Valu e 80.9 82.0 81.1 82.0 82.0 82.0 82.0 82.0 82.0 82.0 -

Colo r Red Red Red Red Red Red Red Red Red Red X X X X X X X X

Table 4: Test result on Green surface for different brightness level Code

Leve

RED

GREEN

BLUE

Reading Volt Valu e 2.90 181 3.26 205 3.37 213 3.54 224 3.41 216 3.57 225 3.70 234 3.65 230 3.57 225 3.76 238 X X X X X X X X -

Reading Vol Valu t e 2.60 162 2.43 153 2.57 161 2.36 148 2.40 152 2.84 178 2.68 169 2.64 166 2.68 169 2.88 182 X X X X X X X X -

Valu e 49.0 49.0 49.0 49.0 49.0 49.0 49.0 49.0 49.0 49.0 -

Color Green Green Green Green Green Green Green Green Green Green X X X X X X X X

Table 5: Testing result on Blue surface for different brightness level

Figure 6: RGB Color Wheel

Code

1 2 3 4 5 6 7 8 9 10 11 12 14 15 16 17 18 19

Reading Vol Valu t e 2.27 142 3.29 201 3.15 198 3.09 195 3.09 195 3.24 204 3.25 204 2.94 185 3.16 200 3.10 196 X X X X X X X X -

RESULT

19/8 19/7 19/6 19/5 19/4 19/3 19/2 19/1 19/01 19/02 19/03 19/04 19/05 19/06 19/07 19/08 19/09 19/01 0

Leve l 1 2 3 4 5 6 7 8 9 10 11 12 14 15 16 17 18 19

RED Reading Vol Valu t e 2.47 155 2.30 144 2.26 142 1.55 97 2.00 125 2.08 130 2.77 174 2.21 139 3.19 201 3.37 213 X X X X X X X X -

GREEN Reading Vol Valu t e 2.35 147 1.78 111 2.00 125 1.56 97 2.28 143 2.20 138 2.57 162 2.35 148 2.62 165 2.71 170 X X X X X X X X -

BLUE Reading Vol Valu t e 2.70 170 2.82 177 2.97 188 2.49 156 3.23 203 3.33 209 3.40 214 3.32 209 3.59 226 3.67 232 X X X X X X X X -

RESULT Valu e 0.5 0.5 16.0 16.0 16.0 16.0 16.0 16.0 16.0 19.2 -

9. Conclusion and Future works Fuzzy logic based systems are popular and proven to be successfully implemented in diversified areas and most colleges and universities offering fuzzy logic courses. This paper has described the development of a low-cost fuzzy logic system used in solving RGB color classification. The system can be use for educational purposes to enables students understand fully logic algorithm in solving problems. In the next development, the system will be enhanced to by implementing the following: • Further tuning to classify and detect a slightly different Red, Green and Blue color. • The inference engine will be written using highlevel programming language and programmed

4/4

Color Blue Blue Blue Blue Blue Blue Blue Blue Blue Blue X X X X X X X X

ETERD’10 Proceeding 2010 P j directly into a microcontroller replacing the need of MATLAB Fuzzy Logic Toolbox. These will enables student to acquire hands-on experience on developing Fuzzy Logic applications.

10. References [1] Ferat Sahin, “A Radial Basis Function Approach to a Color Image Classification Problem in a Real Time Industrial Application”, 27 June 1997, Blacksburg, Virginia, page 1-16, 26 Feb 2006. [2] http://www.glassescrafter.com/information/how-eye-seescolor.html [3] http://en.wikipedia.org/wiki/RGB_color_model#cite_refRWGHunt_2-1 [4] Naotoshi Sugano, Shou Komatsuzaki et al., “Fuzzy Set Theoretical Analysis of Human Membership Values on the Color Triangle”. [5] M. Negnevitsky, “Artificial Intelligence,” in A Guide to Intelligent Systems, Second Edition, Pearson Education, Edinburgh: Addison Wesley, 2005. pp. 112.

5/5

Suggest Documents