Miyerkules, Oktubre 12, 2011

Activity 15 - Pattern Recognition


The human brain is such a magnificent organ with a huge capacity for logic and intellect. Machines and computers today don’t compare to the complexity of an average human brain. The human brain has the aptitude to classify features together and draw inference from a set of objects. An active research today is to construct a computer which has the pattern recognition abilities of a human brain.

A pattern is a set of characteristics or features. Color, shape, size are a few characteristics that is quantifiable in an image.  Set of patterns that share similar properties are called class. Pattern recognition aims to decide if a given feature belongs to one of several classes.

For this activity, I assembled sets of coins for this activity. Each independent class has 10 objects with the same properties. The samples are divided into two groups: the training set and the test set. The training set is the five coins in the while the test set is the five coins in the left for each image. The objects used here are 1 peso coins, 5 peso coins and 25 centavo coins. 

Figure 1. Image of ten 25 centavo coins


Figure 2. Image of ten 1 peso coins




Figure 1. Image of ten 5 peso coins



The features I chose to get from these sets are perimeter, area, and green-channel chromaticity. I was able to extract the area and perimeter on the training set by using the code in the previous activity. These features will be our feature vector. They are tabulated in table 1 below. 


Feature Vector

Training
Area
Perimeter
Green-Channel Chromaticity



25 cents
1
1320
128
0.364468
2
1194
122
0.370987
3
1385
131
0.377735
4
1256
125
0.361357
5
1256
125
0.367904


1 peso
1
1963
157
0.380245
2
1734
147
0.379551
3
1809
150
0.371178
4
1734
147
0.378921
5
1809
150
0.379221


5 peso
1
2123
163
0.358633
2
2375
172
0.364429
3
2463
175
0.367722
4
2375
172
0.362215
5
2290
169
0.359801


Notice that the values of perimeter and area in pixels are very large compared to the average green chromaticity. If we use these values, the perimeter and area would dominate the green chromaticity. To solve this we normalize the values. We divide all the areas with the largest value on our objects which was 2463. We do the same with the perimeter and divide it by 175. The normalized values are shown below in table 2.



Feature Vector

Training
Area
Perimeter
Green-Channel Chromaticity


25 cents
1
0.536033
0.732143
0.364468
2
0.485013
0.696428
0.370987
3
0.5625
0.75
0.377735
4
0.510204
0.714286
0.361357
5
0.510204
0.714286
0.367904


1 peso
1
0.797194
0.892857
0.380245
2
0.704401
0.839285
0.379551
3
0.734694
0.857143
0.371178
4
0.704401
0.839285
0.378921
5
0.734694
0.857143
0.379221


5 peso
1
0.862245
0.928571
0.358633
2
0.964605
0.982143
0.364429
3
1
1
0.367722
4
0.964605
0.982143
0.362215
5
0.929847
0.964285
0.359801


After normalizing, we take the mean feature vector of the classes. The mean feature vector is seen on table 3 below.



Mean feature Vector, m
Area
Perimeter
Average
25 cents
0.508068
0.7125

0.367909

1 Peso
0.741454

0.860714

0.377561

5 peso
0.951021

0.975

0.364033


 
We then get these features on the test objects. We use the same process used in extracting the features on the training set. The values are shown in table 4.

 
        
Feature Vector
Test Object
Area
Perimeter
Green-Channel Chromaticity


25 cents
1
1256.637
125.6637
0.364127
2
1194.59
122.5221
0.368932
3
1134.115
119.3805
0.372138
4
1320.254
128.8053
0.363312
5
1194.59
122.5221
0.368129




1 Peso
1
2042.82
160.2212
0.385217
2
1885.741
153.938
0.376219
3
1661.902
144.5132
0.372638
4
1809.557
150.7964
0.374298
5
1809.557
150.7964
0.378125


5 Peso
1
2290.221
169.646
0.356125
2
2290.221
169.646
0.357149
3
2375.829
172.7876
0.364589
4
2463.008
175.9292
0.390125
5
2375.829
172.7876
0.359537

 
We also normalize these values using the area and perimeter used in the training set. The normalized values are shown in table 5.

        
Feature Vector
Test Object
Area
Perimeter
Green-Channel Chromaticity


25 cents
1
0.510204
0.714286
0.364127
2
0.485013
0.696428
0.368932
3
0.460459
0.678571
0.372138
4
0.536033
0.732143
0.363312
5
0.485013
0.696428
0.368129




1 Peso
1
0.829401
0.910714
0.385217
2
0.765625
0.875
0.376219
3
0.674745
0.821428
0.372638
4
0.734694
0.857143
0.374298
5
0.734694
0.857143
0.378125


5 Peso
1
0.929847
0.964285
0.356125
2
0.929847
0.964285
0.357149
3
0.964605
0.982143
0.364589
4
1
1
0.390125
5
0.964605
0.982143
0.359537


 
After doing this, we can now move on to classification. The class membership of each test object can be determined by finding the class where its feature vector is the closest. Using The Minimum Distance we can now classify them.

Equation for Eucledian distance




Equation for Eucledian norm

We classify x to the class with the smallest distance. The Eucledian distance of the test object is shown in the table below.




Classification
d for 25 cents
d for 1 peso
d for 5 peso


25 cents
1
0.007702
0.391112
0.701625
25 cents
2
0.040143
0.429356
0.749479
25 cents
3
0.085769
0.468561
0.795096
25 cents
4
0.052208
0.348241
0.658565
25 cents
5
0.03934
0.430159
0.748676
25 cents




1 Peso
1
0.536855
0.14561
0.20709
1 Peso
2
0.428367
0.039802
0.297582
1 Peso
3
0.280334
0.110918
0.438453
1 Peso
4
0.377658
0.013594
0.344449
1 Peso
5
0.381485
0.010891
0.348276
1 Peso


5 Peso
1
0.685344
0.313396
0.039799
5 Peso
2
0.684324
0.312372
0.038769
5 Peso
3
0.7295
0.357552
0.021276
5 Peso
4
0.801648
0.4104
0.100072
5 Peso
5
0.73455
0.362604
0.02522
5 Peso


 I highlighted the one with the minimum distance and classified the test object to its corresponding class. The result of the classification gives a 100% correct results.

II would give myself a grade of 8/10 for being able to do this but posting it late. I would like to thank Tino Borja for giving me idea on how to do this

References

1. Soriano M.Pattern recognition AP 186 2011
1. Soriano M. Area Estimation for Images with Defined Edges  AP 186 2011