In this activity, we were asked to perform classification of different images through pattern recognition. This would be done by assembling different objects, which can be classified into 2 to 5 classes. Half of these will serve as training sets, whereas the other half will serve as test sets. These training set are used to distinguish one class from another.
The objects used were fishballs, kwekwek, pillows, and squidballs. I assembled 8 pieces of each of the objects, and classified them using 4 features , which are, the ratio between the height and the width, and each of their R-G-B values.
The objects used are shown below.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVt6-ne7AAWy8jMhLh-KtGaGR4BS7-DRgBa9FZjd-oQ8VUvFK0PYd5VNYhVA9JIGFR9YGghVHUxJ0Tdg8-BSIJx_FyItNAxxODSSAx3ACXSJlHir84JTNh_uWQa9x1rf0UWiVIfhYUkA/s200/kwekwek.JPG)
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBoyXWSNmqsKNmbDDpepB3nnrzNc_ayxQKtRV0Gbe75u7mJe5FK00fEI2OY95GXiUOcXbc7qwcgz-xSkNeXFuUByyNCSfmyLUyVsikAZwSUhwIcpBKYjsMHXJN8pLLy3DO-SzbXv02vQ/s200/pillows.JPG)
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTzeOQgIqO27CmGZ7hTFnFZSFEaBm5NxKTVgXsPH_vMMMBa1rXbUX2pNvdnK5O8G5S9ZAwmlJfJ-aYR-0ZVX7XYfkg5uJvXFAfcF4LGP40hjXYwv5p3ltQzvQhxG06IxTSG1wssdEoPA/s200/squidballs.JPG)
The images were first converted into grayscale before the threshold value of the images were determined using their histogram, to be able to properly binarized it.
The feature vectors are represented by x, and N is the number of the objects in the each class j.
Below are the feature vectors of the objects.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEja5cyS8BIECaAAnzUBD5Ua-xaxBxes7Q9kvWRMvlVCW9JfMe_M5j_Kbe1nL7Edaa6im5fhVeq8qrGVcAp9pDFd4tmn7Tw8PMzBYYeyItnzAtAiK5l-I-aB2WlRcfWy5JIR5gIsHAz8nw/s400/features.JPG)
To determine in which class an unknown feature vector belongs, the feature vector mean given by the equation below is taken.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwd2H-ZUqkoGzthSb1RkbpjZAZxJT_ZIyiVoffhDfRCHMQEMQlhb3P-kWSJ4vj6vUSFEbHuwRYBwDsFa2XMv5hHVLK6k6LBIMWBboSl5e-kMqtYeWNWzy4OJAYYy4EQLAki1-h7Ywyzg/s200/D.JPG)
The calculated means are tabulated below.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimccTOzL8GiFj1gMyJ3clEWazbuTMf3Lf21DAQBQK5KQ7j3urb3z_-3NE-T4AcuH7lYOdbpe-gTCDs7jDItOtnWifImbors1C9e0D650jKTtqMGih-czDuZcLwk8qkwQvlwV40rvNYGw/s400/mean.JPG)
The calculated mean will then be used to determine the Euclidean distance, D.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPj7D2JbTfJansbJofl9rx2_Of4kiFnOhcA9se21Kh7OIb1F3H1I4CLVods_wAUUkklK05S-kprT0ivjiog2tPvRwmZDhSVVZpn_stKMKdJpQunXrg_uKYkdZ10yAYKyMBtgsBqatWmA/s200/D2.JPG)
Finally, the class in which minimum Euclidean distance was calculated, is the assigned class of x.
Results from the table below show that 100% of the objects were properly classified.
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgc1s1YzsNaEZ1fdP-TpN4_D4nt9ywSX_8YlkDRHWyT74R2OtipTenanJpWA_7wgcaiq1Y-FONu7ah2ya7cq-9rlp34s5Og12l-8rwHmVxZca_KLSAdhfcrKwtk2e2Ui-_uKSSgrGEeug/s400/results.JPG)
rating: 10 because proper classification of the objects was done!
acknowledgement: Angel and Marge for helping me with the program.