In this activity, we try to test if a random object can be classified using pattern recognition. First, we obtain 8-10 pieces each of similar objects like leaves, fishballs, potato chips, etc. One category of objects is called a class. We assemble 8-10 objects that can be classified into 2-5 classes. Half of this will be used as a test set and the other as training set. In this case, I have assembled 8 pieces each of:
1. pillows (a chocolate-coated snack)
2. piatos potato chips
3. squidballs
4. kwek kwek (orange, flour-coated quail egg)
We extract certain features of these objects such as size, shape, and color and arrange these numbers into an organized set called a feature vector. For each individual object, the feature vector that I will use will have four dimensions namely:
1. ratio of length to height of object (x-axis/y-axis)
2. red component of color
3. green component of color
4. blue component of color
After finding these values for our 32 objects in total, we tabulate them in order to try to visualize clustering in 4-D feature space. We expect clustering to happen if objects are similar to each other. Thus, piatos chips should be clustered together with other piatos chips since they are similar in both size and color.
To calculate for the size, I employed the following algorithm. Assuming that the each object under one class is depicted in one image, we open it in Scilab, convert to grayscale, look at its histogram to find the proper threshold value in order to convert it to B&W. After that, we do morphological operations to clean the image (close holes and connect/remove stray pixels). Then we use the follow function to measure the contour of the object, get the maximum and minimum values in the x and y axes, and find their ratio. To calculate for the color, we need to first separate the region of interest from the background. Once that is finished, we get the mean for each color channel. These numbers constitute our feature vector for each object. There are 8 objects each for 4 classes used so there are 32 feature vectors.
____________________________________________________________________
Shown below are the values for the feature vectors. For each class, half will be used as a test set and the other half as a training set.
____________________________________________________________________If we have any other random object, we can say whether it belongs to the class of squidballs or pillows through a method called minimum distance classification.
source: M. Soriano, A18- Pattern Recognition.pdfWe use the training feature vectors to find the class representatives mj. Then, we classify the test feature vectors using this method.
____________________________________________________________________
class representatives or mean feature vector, mj:
1. kwek kwek - [0.96, 0.75, 0.39, 0.04]
2. squidballs - [1.03, 0.55, 0.35, 0.09]
3. pillows - [1.00, 0.32, 0.17, 0.08]
4. piatos - [1.35, 0.59, 0.45, 0.16]
From this table it can be seen that only 2 out of the 16 objects were classified incorrectly. Thus, the success rate of this method is 87.5%. Errors may have come from the calculation of the length to height ratio because the images might not have been thresholded and/or morphologically enhanced correctly.____________________________________________________________________
I give myself 10 points for this activity since the method was implemented resulting in only a few errors. The success rate of this method in pattern recognition was found to be 87.5%, which is a fairly acceptable number. Thanks to JC Nadora, Benj Palmares, Raf Jaculbia, Mer Camba, Ed David, Billy Narag, and Jorge Presto for buying the objects/food tested (kwek kwek, squidballs, piatos, pillows).
0 comments:
Post a Comment