When we look at objects, we can instantly classify them in groups according to certain features such as color, shape, size, texture, etc. This classification is simulated in this activity by taking pictures of objects such as leaves, coins, and flowers and extracting features by which the objects can be classified. The collected images are then divided into two: the training set and the test set.
25 cent coin | flower | long leaf | rectangular leaf
The training set will be used to gather information about a certain class. To evaluate the success of classification, the test set is used. The classification is based on the object features, which should be unique for each object class.
Features
Features which can be used to differentiate between the objects are extracted. For the objects above, the features used are eccentricity and the ratio of the object area and the square of the object perimeter. The features chosen are scale-invariant: even if the image is large or small, the features should not change. This is important because the method should still be able to classifiy the objects at any image scale. Eccentricity is the measure of how a conic section deviates from being circular [1]. The eccentricity is given by:
where a is the length of the semi-major axis and b is the length of the semi-minor axis. For this feature, the objects are assumed to be elliptical. The major axis is the length of the widest part of the image and the minor axis is the length of the thickest part of the image.
Another feature used was the ratio of the area and the square of the perimeter. Initially, I thought this could differentiate the images well because each shape has a unique area and a unique perimeter. The perimeter had to be squared so that the feature is unitless.
Image processing methods
The images were cropped such that each sub-image contains only one object. The sub-images are then binarized. The features are extracted from these binary images.
Cropped images and their binarized counterpart.
For the eccentricity, the length of the major axis was measured in pixels by taking difference between the column indices of the first and last column where a white pixel is present. The length of the minor axis was measured using the same procedure, but for the row indices this time.
The contour coordinates were obtained using the follow command in Scilab. The area was determined by using Green's theorem (discussed in Activity 2) and the perimeter was measured from the contour as well.
Minimum Distance Classification
The mean of the features for each class in the training set was obtained, and using the equation below, the closeness of a certain set of features of an object in the test set to a certain class is calculated.
The test object belongs to a class if the d of the object to the class j is maximum.
Results
Plotting the features, as in the figure below, we can see that the features are well differentiated.
The classes are well separated from one another. The features are clearly clustered into four classes, which are named 25cent, flower, rectleaf, and longleaf.
The minimum distance classification was applied to the test images, and the results are summarized in the tables below.
The highest value is highlighted. For each test sample, the column with the highest value is where it is classified. For example, the test sample 1 of the 25 cent class is correctly classified to the 25 cent class. Sample 6 of the flower class is incorrectly classified to the 25 cent class. The classification counts are summarized below.
There are 5 test images for the 25 cent class, 7 for the flower, 8 for the rectangular leaf, and 5 for the long leaf, for a total of 25 images to be classified. Only 2 images were incorrectly classified, which means that the method is correct 25 times out of 27, which gives a 92.6% accuracy.
The prediction accuracy of 92.6% is more than three times than if classified by chance, with a chance proportion criterion of 26.08%. The chance proportion criterion is given by
where p1 is the population of sample 1 (25 cents) and so on, and P is the total population.
--
I give myself 10 points for this activity. I was able to select features which enabled the method to correctly classify the objects with 92.6% accuracy.
I would like to thank Master for useful discussions.
--
Recommendations
Since the objects are colored, other features that can be used are the color information.
[1] Eccentricity (http://en.wikipedia.org/wiki/Eccentricity_%28mathematics%29)
0 comments:
Post a Comment