Isolating Healthy Bananas from Unhealthy Ones Based on Feature Extraction and Clustering Method Using Neural Network

Due to the high sorting speed required during inspection and classification in packing lines, most of the current automatic systems, based on machine vision, are used. Fruit industries are not excluded about this fact. In this paper a method is proposed for detection healthy bananas and defective one. Our algorithm has 4 steps. First, we eliminated background using segmentation methods such as FCM, HCM, Kmeans. Then we extracted the boundaries of a sample banana using edge detection approach. After that, feature from surface of a sample was extracted. Finally, by using a neural network, healthy bananas and defective one was detected.


Introduction
Agriculture products are being more demanding in market today.In order to increase its productivity, speed and eliminating human errors due to hard conditions, automation to produce these products will be very helpful(S.A. R. A. B. M.M. Mokji, 2006).
Using image processing technology and machine vision in recent decade had much progress in minor and major industries.At the present, human operator does detecting defections in factory.As intelligence level of human operator is decreased gradually, by difficult conditions of working environment such as air pollution, sound pollution.It is probable that some surface defection is hidden from human operator's eye(M.S. Mansoory, H.tajik, G.Mohhamadi, M.Pashna 2008), so developing an image processing system seems necessary.
Segmentation is frequently used to separate significant regions from background.Hence, accurate image segmentation is the primary component in many image-processing applications.

Image acquisitions
This section describes how corresponding digital images are acquired for the conducted experiments.The imaging system consisted of a digital camera with silicon CCD detector connected to a lens assembly.The camera was attached to a computer with MATLAB software capable of capturing image.
In order to use computer vision to evaluate objects by proposed algorithm, it is important to create a uniform light field around the object.To achieve this and additionally to eliminate any effect of environmental light, a cubic box of 0.80 × 0.80 × 0.80 m with white reflecting walls was constructed.
The bananas were rotated around the longitudinal axis by the rollers.The rollers and the bottom of the frame were colored in blue in order to simplify the separation of the banana from its background.Above the set-up, a digital camera was placed and directed to the frame.This camera acquires images taken in the red-green-blue color space (640 × 480 pixels) of the banana at 30 frames per second.

Proceeding of image analysis
After image acquisition, images are given to MATLAB software as an input image.Then this image, which is color image, is transformed to gray level image by the following formula, I=(R+G+B)/3 (1) In this formula R is the red component of a sample image and G is the green component and finally B is the blue component.The used method in this article has 4 steps.
1) Background elimination using clustering method 2) Finding the edge of a sample using SUSAN edge detector 3) Feature extraction using texture analysis 4) Applying neural network as a classifier.

Background Elimnation
Among of the clustering method such as K-Means (O. S.  . Pal. 1991).In this work, the FCM algorithm has been applied to perform the classification.This algorithm is an iterative clustering method and presents some advantages with respect to other classifiers.
The fuzzy c-means (FCM) algorithm is one of the most wildly used methods in fuzzy clustering.It is based on the concept of fuzzy c-partition, summarized as follows, Then the fuzzy c-partition and space for x is a the set The aim of the FCM algorithm is to find an optimal fuzzy c-partition and corresponding prototypes minimizing the objective function is Euclidean norm, and the weighting exponent m in ] , 1 [  is a constant that influences the membership values.
To minimize criterion m J , under the fuzzy constraints defined on (3), the FCM algorithm is defined as an alternating minimization algorithm, as follows.Choose a value for c , m and  m a small positive constant; then generate randomly a fuzzy c-partition 0 U and set iteration number 0  t .A two-step iterative process works as follows, given the membership value given the new clusters The process stops when or predefined number of iteration is reached.

Finding the Edge of Banana
The Smith edge detector (S.M. Smith and J.M. Brady, 1997) is different from the other detectors in nature.Each pixel in an image is used as the center of a small circular mask.The grayscale values of all the pixels within this circular mask are compared with that of the center pixel (the nucleus).All pixels with similar brightness to that of the nucleus are assumed to be part of the same structure in the image.
Figure 1 shows the masks with pixels of similar brightness to the nucleus colored black, and pixels with different brightness colored white.Smith calls the black image area the Univalue Segment Assimilating Nucleus (USAN) In SUSAN algorithm, the mask (see figure 2) is placed at each point of the image and, for each point, the brightness of each pixel within the mask is compared with that of the nucleus (the center point), originally a simple equation determined this comparison, Where 0 r  is the position of the nucleus in the two dimensional image, r  is the position of any other point within the mask, ) (r I  is the brightness of any pixel, t is the brightness difference threshold and c is the output of the comparison.This comparison is done for each pixel within the mask and a running total, n , of outputs ( c ) is made, This total n is just the number of pixels in the USAN,i.e.it gives the USAN's area.For a edge to be detected, a local minimum in n must be found, That is, differentiating with respect to both components of 0 r  must give zero.( n ) must also be below the geometric threshold).Thus, using equation7 and 8, this function B has the property of picking out the narrow bands that lie on boundaries between the univalve regions; it is zero everywhere apart from fairly sharp peaks centered at

Feature Extraction
For extracting feature, we used properties of a Gray-Level Co-occurrence Matrix (GLCM) (Sonka M, 1998).GLCM is the matrix that defined by calculating how often a pixel with gray-level (grayscale intensity) value i occurs horizontally adjacent to a pixel with the value j (Figure 3).
We explain some of these features (Haralick RM, Shapiro LG. 1993) as follows: Entropy: a term more commonly found in thermodynamics or statistical mechanics.Entropy is a measure of the level of disorder in a system.Image of highly homogeneous scenes have high associated entropy, while in homogenous scenes poses a low entropy measure.The GLCM entropy is obtained with the following expression.Contrast: it is a measure of the difference between intensity values of the neighboring pixels.It will favor contributions from pixels located away from the diagonal of ) ,


Where Nc are the number of occurrences and L is the number of gray level variations.
Homogeneity: this gives a measure of how uniformly a given region is structured, with respect to its gray level variations.


Local homogeneity: this measure provides the homogeneity of the image using a weight factor which gives small value for none-homogenous images when 1(15) Directivity: this measure provides bigger value when two pixel regions with same gray values are separated by a translation.

 
( 1 ( 16) Uniformity: this a measure of the uniformity of each gray level Maximum probability: considering the GLCM as an approximation of joint probability density between pixels, this operator extracts the most probable difference between pixel gray scale values )) , ( max( Correlation: this is measure of gray scale linear dependencies between pixels at the specified positions relative to each other.

Neural Network Classifier
The perceptron is the simplest form of a Neural Network used for the classification of a special type of patterns said to be linearly separable (i.e., patterns that lie on opposite sides of a hyperplane) (Hykin, Simon).The algorithm used to adjust the free parameters of this Neural Network first appeared in a learning procedure developed by Rosenblatt (Rosenblatt, F., 1958) (Rosenblatt, F., 1962) for his perceptron brain model.Multilayer perceptrons have been applied successfully to solve some difficult and diverse problems by training them in a supervised manner with a highly popular algorithm known as the error back-propagation algorithm.Neural Networks can have several layers.In multilayer feedforward networks the direction of signals is from input to output, there is no feedback in the layers.The diagram below (Figure 4) shows a 3-layered feedforward network (Callinan, Tim., 2003).
The input layer had 10 neurons for the first ANN classifier, because of, 24 neurons for the second, and 2 neurons for the third one using wavelet transform.The number of classes desired determined the output layers.In our study, the 2 neurons of the output layer correspond to the healthy bananas and unhealthy bananas.In practice, the number of neurons in the hidden layer varies according to the specific recognition task and is determined by the complexity and amount of training data available.

Results and conclusion
A sample banana image was captured (Figure 5) and then it was converted to gray level image (Figure 6).After that FCM algorithm was done to eliminate object from its background (Figure 7).
In addition to higher speed, the reason of using FCM is that the distance function versus iteration started at the lower value and with the less iteration it will be converged (Figure 8).SUSAN edge detector uses no spatial derivatives at all.The Smith corner detector does not require any smoothing and so there is no degradation in localization accuracy due to smoothing.
For evaluating SUSAN algorithm, in comparison to some common edge detectors such as Canny (Albovik, 2000), Perwit (Albovik, 2000), Sobel(Albovik, 2000) and Roberts (Albovik, 2000), we added a Gaussian noise with variable level of noise variance; the variances were between 0.001 and 0.0105.We tested our algorithm for the all of the images in the database.To demonstrate the performance of the proposed algorithms, a sample of five hundred bananas, 350 defective and 150 healthy, were analyzed for sorting purposes and final inference for acceptance or rejection.The results are shown in the following figure.
We used one network structure of 10-24-2 (i.e.eight neurons at the input layer, twenty four at the hidden layer and two at the output layers), and the two other structures respectively of eight-three-two and eight-four-two.In practice, the number of neurons in the hidden layer varies according to the specific recognition task and is determined by the complexity and amount of training data available.If too many neurons are used in the hidden layer, the network will tend to memorize the data instead of discovering the features.This will result in failing to classify new input data. .To generate an efficient network, different learning coefficients and momenta were selected for different layers.In the present work, the normalized root-mean-square (RMS) error of the output layer was used as a criterion to select these parameters.The selected learning coefficients and momenta correspond to the deepest slope of the normalized RMS error.Using the hyperbolic tangent sigmoid as the neural transfer function, the input feature vectors were scaled to the range from -1 to +1 to fit into the dynamic range of this function.Before the training process was started, all the weights were initialized to small random numbers.This ensured that the classifier network was not saturated by large values of the weights.The results of using neural network are shown in the following tables (Table 1 dxdy is the elemental area within the mask.(The summation has been replaced by a double integral.
moments express common statistical information, such as the vaiance for that corresponds to second moment.thisdiscriptor increase when the majority of the valuee of Inverse moments: this produce the opposite effect compared to previous descriptor

Figure 1 .
Figure 1.Four Smith edge finding masks at different positions in an image (S.M. Smith and J.M. Brady, 1997)