26 Iccs18cs132
26 Iccs18cs132
Abstract— A new method for classifying fruits using image processing technique is proposed in this paper. The data set used
had 70 apple images and 70 banana images for training and 25 images of apple and 25 images of bananas for testing. RGB
image was first converted to HSI image. Then by using Otsu’s thresholding method region of interest was segmented by taking
into account only the HUE component image of the HSI image. Later, after background subtraction, a total of 36 statistical and
texture features were extracted with the help of the coefficients obtained by applying wavelet transformation on the segmented
image using Haar filter. Extracted features were given as inputs to a SVM classifier to classify the test images as apples and
bananas. As KNN classification method did not give 100% accuracy while classification SVM classification method was used.
140 sample images of apples and bananas were used for training and 25 images of banana and 25 images of apples were used
for testing the proposed algorithm. The proposed algorithm gave 100% accuracy rate.
Keywords— RGB, HSI, Region of interest, Wavelet domain, Haar filter, SVM classification.
used. In order to classify fruits commonly extracted features 3.4 Proposed Algorithm
are related to the statistical, colour, intensity, shape and The steps involved in the proposed method are depicted in
texture. For this experiment statistical and texture features the algorithm given below.
were used.
Algorithm :
3.1 Samples used 1 : Load RGB image
For experimentation a total of 140 images were taken for 2 : Convert RGB image to HSI image
training and 50 images was taken for testing. Out of these 3 : Taking the Hue component image and
140 training images, 70 apple images [granny smith, fuji, red subtract its background
delicious variety and 70 banana images [yellow and green 4 : Obtain ‘T’ threshold using OTSU’s method
variety] were taken and out of 50 test images 25 apple 5 : Extract the ROI using the same and fill the holes.
images [granny smith, fuji and red delicious variety ] and 25
banana [yellow and green] images were taken. 6 : Image with ROI alone is loaded
3.2 Image Acquisition 7 : Features like statistical and textural features were
RBG colour images can be acquired using a Digital camera extracted using Wavelet Transformation using
using an illumination chamber. All secondary images used Haar filter for all Vertical, horizontal and
for this research work were of sizes 800 x 800 pixels. diagonal coefficient values
8 : Extracted features from both training and testing
3.3 Proposed Method samples were given as input to SVM
The proposed method uses the following steps which have classification procedure.
been depicted using a flowchart below. This proposed 9 : Apple images and banana images were classified.
algorithm was coded and was executed using MATLAB
2017a software. As the first step region of Interest was 3.5 Region of Interest extraction
extracted from the extracted apple’s / banana’s image. After In this work the apple/banana image area was the Region Of
identifying the region of interest, the segmented image’s Interest. To extract the ROI, the acquired RGB image was
background was subtracted and the holes were filled using converted into HSI colour space. Hue component image was
morphological procedures. Then wavelet transformation taken into account for further study. After conversion the
using Haar filter was applied on the ROI image. A total of 36 background of the image was subtracted. Then ‘Th’ value
statistical and texture features using the diagonal, vertical was obtained using Otsu’s method. Here gri(x,y) was the
and horizontal coefficient values of the wavelet domain were background subtracted image.
extracted. Using the extracted features of apple/banana ( )
images were well classified using SVM classifier as images ( ) {
( )
of apple and bananas. The following flowchart depicts the (1)
proposed algorithm.
Image holes may be there in the segmented image therefore
Acquired these image holes were filled using some morphological
apple image procedures to get the final ROI image.
STEP 1
ROI extraction 3.6 Feature extraction
This subsection discusses about the features that were
extracted to classify the apple and banana samples using the
STEP 2 proposed algorithm.
Feature extraction using wavelet
transformation using Haar filter 3.6.1 Wavelet transformation
Images in general are not always clearly defined in special
domain. This in turn will not help in accurate classification.
STEP 3 So, DWT (Discrete Wavelet Transformation) coefficients of
Classification using SVM classifier diagonal, vertical and horizontal pixel values were obtained.
Further statistical and texture features were calculated using
these level one coefficient values and level two coefficients.
Apples Bananas Haar filter was used to decompose the images.
For first and second level decomposition of the segmented groups here the objects are green and red colours with a line
image, statistical features like mean and standard deviation that correctly classifies new objects called test cases on the
were calculated. A total of 12 features [ Mean value for CH , basis of the examples that are available as train cases.
CV , CD and Standard Deviation for CH , CV , CD] for each In the proposed methodology, SVM classification was used
image was calculated. to classify the apples and bananas under two headers and was
stored in two separate folders.
Mean = µ = ∑ ∑ ( ) (2)
IV. RESULTS AND DISCUSSION
√( ( ) )
Standard Deviation = = (3)
4.1 Results
Out of 50 test images used for testing 12 test image samples
3.6.3 Texture features results are taken for discussion in this section. After STEP 1
Texture features like Energy , Homogeneity , Contrast and phase of the proposed methodology the following output was
correlation for CH , CV , CD at first and second level obtained.
decomposition of DWT was calculated. And a total of 24
features were obtained.
Energy = √∑ ∑( ( ) (4)
i j
Energy give us the sum of squared elements.
( )
Homogeneity = ∑ ∑ ( )
(5)
Contrast = ∑ ∑ ( ) ( ( )) (6)
( )( )
Correlation = ∑ ( ) (7)
(b)
Figure 3. a) RGB image original image , converted HSI image , Hue
component image and image after morphological procedure of an apple
Figure 2. SVM Classifier illustration diagram sample. b) RGB image original image, converted HSI image, Hue
component image and image after morphological procedure of a banana
Figure 2 illustrates a SVM classifier diagrammatically. SVM sample.
classifier separates a set of objects into their respective
From the above figures a and b it was evident that the Hue Table 4. Statistical features at level two.
component image of an apple/banana image gave a clear
picture of the ROI. Also, figures a and b also shows images
that were obtained after the background subtraction
procedure and the image that was obtained after the
application of Otsu’s thresholding algorithm.
Table 2. Statistical features at level one In the above scatter diagram ‘x’ represents a banana image
and ‘+’ represents an apple image. Out of the 12 test sample
images 5 images were banana images and 7 images were
apple images.
(b)
Figure 5. (a) Apple test images (b) Banana test images
REFERENCES