Fruit Classifier
For the Classification
of Fruits via Software MATLAB we need to have concept about three main points.
1- Database
The database contains
the images of fruits in a folder. The classifying fruits are more than one
category so for each category there must be separate folder .e.g. Apples in one
folder, Pears in second folder and so on.
|
Sample Images for Apple |
|
Sample Images for Pineapple |
For the project
simulation in MATLAB, we have used five different Fruits.
- Apples
- Bananas
- Dates
- Oranges
- Pineapples
Some sample images for
Pineapple and Apple are shown above.
2- Feature Extractor
It is a method that
stores some part of information instead of complete image. It is helpful
because instead of saving all image some samples are stored from it.
For every fruit we
have collected 10 samples (For MATLAB Simulation). Out of 10 samples, features
of 7 samples are used for training of network while features of 3 samples are
used for testing of network. The feature extractor returns 6 features for each
sample.
Total Number of Samples = Samples for each
fruit x Number of fruits in database
Total Number of
Samples: 10 x 5 = 50
Samples for training
of Network: 7 x 5 = 35
Samples for testing of
Network: 3 x 5 = 15
Below shown is the workspace for project. It contains training and testing data along with targets
matrix.
|
Project Workspace |
In below text
following words are used with reference to above figure.
- Training data =
Training_Data
- Testing data =
Testing_Data
- Training Targets =
Training_Target
- Testing Targets =
Testing_Targets
It can be seen from
above figure training data is a matrix of 35 x 6.In training data matrix, 35
means numbers of samples and 6 means features for each sample. It means we have
1 sample in a row for training of network.
It can be seen from
above figure testing data is a matrix of 15 x 6.In testing data matrix, 15
means numbers of samples and 6 means features for each sample. It means we have
1 sample in a row for testing of network.
The training targets
and testing targets means targets for training data and testing data
respectively. After the extraction of features we have to specify that for
which class or fruit the features are extracted. E.g. all the 10 Apple samples
are assigned with same number i.e. 1, all the 10 banana samples are assigned
with same number i.e. 2 and so on till the last sample.
If we combine the
features matrix with respective targets, following result matrix is obtained.
(The result is shown for testing data).
|
Features Vector along with Targets for Testing Data |
In above figure from
column 1 to column 6 are the features for each sample and column 7 means the
target for each sample. First 3 samples column 7 value is 1 which means they
belong from fruit category 1 i.e. Apple, next 3 samples column 7 value is 2
which means they belong from fruit category 2 i.e. Banana and so on.
3- Classifier
It is the main section
in classification. The features extracted in last step are used to train and
test the classifier. After obtaining of desired result. The Classifier is saved
and used in future for classification.
The results obtained by
testing data for my simulation are;
|
Actual Targets vs Predicted Target by Classifier |
In above figure column
1 represents our required result and column 2 represents the predicted result
by classifier. The accuracy obtained by classifier is 93.333%. Classifier predicted sample 10 as
category 5 while the required result is category 4.
The conclusion for
above discussion is as;
Three main steps fruit
classifier are;
Creation of database:
Collection of images for fruits.
Feature Extraction:
Features are extracted from collected images.
Classification:
Extracted features are classified by classifier in to classes or targets.
That’s all for today.
If you have any query
regarding understanding, kindly mention it in comments or if you need MATLAB
code for Fruit Classifier email me at: ms.solutionsonline@gmail.com
Thank You.
Stay Happy.