A Machine Vision System for Quality Inspection of Pine Nuts

Computers and artificial intelligence have penetrated in the food industry since last decade, for intellectual automatic processing and packaging in general, and in assisting for quality inspection of the food itself in particular. The food quality assessment task becomes more challenging when it is about harmless internal examination of the ingredient, and even more when its size is also minute. In this article, a method for automatic detection, extraction and classification of raw food item is presented using x-ray image data of pine nuts. Image processing techniques are employed in developing an efficient method for automatic detection and then extraction of individual ingredient, from the source x-ray image which comprises bunch of nuts in a single frame. For data representation, statistical texture analysis is carried out and attributes are calculated from each of the sample image on the global level as features. In addition co-occurrence matrices are computed from images with four different offsets, and hence more features are extracted by using them. To find fewer meaningful characteristics, all the calculated features are organized in several combinations and then tested. Seventy percent of image data is used for training and 15% each for crossvalidation and test purposes. Binary classification is performed using two state-of-the-art non-linear classifiers: Artificial Neural Network (ANN) and Support Vector Machines (SVM). Performance is evaluated in terms of classification accuracy, specificity and sensitivity. ANN classifier showed 87.6% accuracy with correct recognition rate of healthy nuts and unhealthy nuts as 94% and 62% respectively. SVM classifier produced the similar accuracy achieving 86.3% specificity and 89.2% sensitivity rate. The results obtained are unique itself in terms of ingredient and promising relatively. It is also found that feature set size can be reduced up to 57% by compromising 3.5% accuracy, in combination with any of the tested classifiers. Keywords—pine nuts; Image processing; neural networks; feature extraction; classification

In recent times, automatic inspection of product good as well as raw ingredients has gained more attention in food industry.Efforts have been made for non-destructive investigation of key ingredients in agriculture and food business.In this context, x-ray imaging has been a preferred technique which lets one examine the ingredient internally without causing any damage to the ingredient itself.It reveals the internal details which allow the presence of worm damage and other defects to be determined in a safe way [1][2][3].In nuts selection, the key objective is to reduce the amount of nuts with navel orange worm damage passed to the consumer.For inspection of the ingredient, image processing is a potential tool for unveiling the hidden damage present inside the ingredient, and to highlight the concealed facts.Work has been carried out in processing the images of food ingredients for identifying the damage present in it [1][2][3][4].However, the efforts made to demonstrate the extraction of individual nutmeats -Regions of Interest (ROI) -are limited, in particular, where an ample image is captured of a large number of ingredients by the x-ray source.In a real time scenario, it is unlikely to activate x-ray source for each individual ingredient, instead, a batch of ingredients can be captured.We demonstrate development of an image processing method which is capable of identifying and extracting image samples of each individual ingredient that passes under the x-ray source, while discarding any external object simultaneously.
Afterward, converting image samples into significant features which hold discriminative properties of the target class is also a vital task.Extensive work has been carried out for classification of agriculture products as well as food ingredients by the use of several kinds of features extracted from their images.Keagy et al. [4] made use of statistical and histogram features for damage detection in pistachio nuts.Guyer et al. [5] used spectral imaging for defect detection in cherries.Park et al. [6] proposed content-based image classification using texture properties and diagonal moment.In extracting significant features for quality inspection of ingredients related to food and agriculture industry, more attention has paid towards texture analysis of images.Considering nuts as food ingredient for quality assessment and sorting, pistachio has been widely used in previous studies [7][8][9][10][11].Hazelnuts and almonds are also studied; however, pine nuts are rarely reported.One of the reasons is its high cost around the globe which leads to its limited consumption in the food industry.In addition, its size is small which limits it to be graded efficiently and autonomously.We used pine nuts as raw food ingredient to develop a machine vision system for its automated quality inspection using x-ray imaging.
In a classification task, the success rate highly depends upon the suitable selection classifier as well.A classifier identifies objects as one of the target classes by using the features extracted from them.Many classification techniques have been used for quality assessment of goods in food and agriculture industry.Among them, Artificial Neural Network (ANN) has shown potential for resolving problems in estimating a mathematical relationship where some inputs and their corresponding target outputs are known [12][13][14].Extensive work has been carried out employing this technique by using several kinds of features including statistical, spectral, texture and color features [15][16][17][18][19][20][21][22][23].Support Vector Machine (SVM) is another state of the art technique, used in binary classification problems [24][25].It has the capability to separate the linear as well as non-linear data by estimating a hyper plane between classes.SVM classifier has been employed in several different applications [26][27][28][29][30].
In this work, the aim of the study is to propose a machine vision system which is initially capable of the extracting image of each unit ingredient (from source image which encompasses the large number of ingredient), and then classify it as healthy or unhealthy (damaged/diseased).We used raw pine nuts for Quality inspection.The technical goals of the study include developing a method for real-time extraction of unit ingredient (individual nut image) by processing the captured image by an x-ray scanner which is possibly mounted above the feeding belt containing non-overlapped nuts in a serial manner.Then estimation of fewer meaningful features to be extracted from each image sample which show a significant contribution to classification, and propose an appropriate classifier model to efficiently grade the sample ingredient as one of the target class.Figure 1 shows the in-line inspection scenario for quality classification of raw pine nuts.
The rest of the paper is scheduled as: Section 2 describes the image acquisition and the method for individual ingredient extraction.Section 3 includes the features choice and their combinations for classification.Classifiers' detail is presented in section 4. The parameters of performance evaluation and the results are discussed in sections 5 and 6 respectively.

A. X-ray Imaging
Raw pine nuts (Unprocessed) are obtained as samples.For the x-ray imaging, we considered an x-ray image reader machine: FCR (Fuji Computed Radiography) PRIMA (Model: CR-IR 391RU) of FUJIFILM Corporation [31].It is the Computed Radiography Machine primarily used for medical imaging.With the intension of developing an extraction method (extraction of invidual nutmeats from the captured xray image) only, and due to the limited resources; this imaging solution is adopted on an experimental basis.The reading capability of the device is 10 pixels /mm and processing capacity is up to 29 IPs (Imaging Plates) per hour.The imaging plate of type ST-VI is used with dimension 35×35 cm.A 24 bit, 1760×1760 output image in JPEG (Joint Photographic Experts Group) format is generated using the FCR PRIMA Console workstation.A sample output image with pine raw nuts laid on the image plate is shown in Fig. 2. Later, each sample was carefully marked, manually internally examined and then labeled as healthy or unhealthy.

B. Pre-processing
The x-ray output image is a wider image containing a large number of raw pine nuts.In the Fig. 1, It is apparent that the background intensity is not constant rather there are vertical background stripes in the image with higher light intensity.The problem occurs due to crude environmental illumination conditions.We obtained such an image due to limited resources, however, it is assumed that for a practical scenario, non-overlapped nuts are laid on the feeding belt, and an X-ray source is mounted on top which captures the image of a batch of nuts (see Fig. 1).For pre-processing and independent nutmeat region extraction from the captured image, few useful image processing techniques are employed discussed in the following.
The obtained digital x-ray image (Fig. 1) is a 24 bit RGB image.It is converted to grayscale image by eradicating the hue and saturation information, while holding the luminance [32].Considering the real-time setup with proper source as indicated in Fig. 1, we show the sample image with few ingredients as shown in Fig. 3a. Figure 3b represents the inverted intensity version.Next, to separate regions of interest from background, the grayscale image is converted to binary image with white color (pixel intensity~255) as the region and black (pixel intensity~0) as background pixel based on global thresholding, where the threshold was selected by trial and error for the current database (see Fig. 3c).For all the detected regions in Fig. 3c, the centroids, and the bounding boxes are calculated [32].Bounding box contains the global coordinates of the top left corner of the region and the rectangular size of the region.These rectangular dimensions are estimated by using the binary image (fig.3c) with the help of edge detection along the horizontal as well as the vertical axes.Centroids (global coordinates of central pixel of the region) are estimated for each region by calculating the mean of global coordinates of pixels belonging to the region along the horizontal and the vertical axes.Figure 3d shows all the detected regions with their corresponding centroids marked on them.There are many tiny regions detected which are not our ROIs.To skip them, a median filter mask of size 5×5 is applied.These false regions act as salt and pepper noise, and so many of them were disappeared after applying the median filter.As an additional benefit of this filter, the boundaries of true regions became sharper as shown in Fig. 3e.

C. True Nutmeat Region Estimation and Extraction
Finally, to detect the correct nutmeat regions only, we approximated the size of a single average pine nut image.So an area-based threshold is used; A=A n ±15%, where A n is the estimated normal nut image area.A region was marked as the true region if it satisfies the threshold criteria or otherwise discarded.The resultant regions with their corresponding centroids can be seen in Fig. 3f.
Figure 3g shows the true nutmeat regions with both corresponding centroids and the bounding boxes.Since the bounding boxes represent the global rectangular measurement of the region, each ingredient is extracted (cropped) from the original image (Fig. 3a) with the help of its corresponding bounding box information.Finally, each individually extracted pine nut sample is shown in Fig. 3 (at the bottom).It is worth mentioning here that each ingredient image is the part of original source x-ray image, and not of the processed image.The processing was done for detection of only real ingredient, and the efficient estimation of their size for successful cropping.
As mentioned earlier, the individual ingredients were manually inspected and labeled as binary label; 0 for healthy, and 1 for unhealthy.Figure 4 shows few image samples representing each of target categories.FEATURE SELECTION Depending on the nature of task, attention has been paid in mining the meaningful and significant information from the images.The aim is to estimate and compute the properties which hold the discriminating characteristics of the image sample representing the target category.
Regarding quality inspection using images, texture analysis have been extensively exercised as discussed in the introduction section.For this quality assessment task, we chose the features providing the multilevel statistical and texture statistical properties of the sample images.

A. Global statistical features
We calculated a set of statistical features on the global level from each of the sample image.For an image I with highest pixel intensity N, these features are calculated by using the mathematical expressions summarized in Tab. 1. Minimum, maximum, and median are the first order features and represent the corresponding pixel intensities in the image.Mean represents the average pixel intensity and the standard deviation is the measure of average contrast.Variance is calculated as the square of standard deviation.These features are mathematically represented in Tab. 1.

B. Texture statistical features on global level
Next, four characteristics are calculated on global level which represents the texture statistical analysis of image presented in Tab. 2. Smoothness represents the measure of relative softness of the intensity in a region, ranging between 0 and 1.A constant intensity image corresponds to zero smoothness.Third moment determines the skewness of histogram of the image.Uniformity is the measure opposite to smoothness; hence a constant intensity image corresponds to maximum uniformity.Entropy is the statistical measure of randomness.Mathematical expressions for calculation of these features are represented in Tab. 1.

C. Texture statistical features from co-occurrence matrices
In addition to global level characteristics, we extracted features from Gray-Level Co-occurrence Matrices (GLCMs).A Co-occurrence matrix is largely used to measure the texture of an image [33].The size of this matrix depends on the number of gray levels present in the image.The elements in the GLCM depend on the position operator, which is described by a vector containing direction and distance parameters (also called offset).We calculated four GLCMs from each of sample images using four position operators shown in Fig. 5. if I p q i and I p x q y j i j otherwise where Δx and Δy represent the horizontal and vertical distances.
From each ingredient image sample, four GLCMs are calculated.Next using each GLCM, following four features: contrast, correlation, energy, and homogeneity, are calculated respectively as; 2 , ( - (5) Where i and j represent pixel intensities and c ij is their count of co-occurrences according to the specified position operator.

D. Features Organization
Concretely, from each image sample, we calculated global statistical features, and statistical texture features on global level as well as from co-occurrence matrices.To assess the significance of different features in classifying the unseen data, we organized these features into six different combinations.These combinations of features are shown in Tab. 2.
Figure 6 shows the flow chart of the entire system including image processing, feature extraction, and classification phases.

IV. CLASSIFIER CHOICE
As discussed earlier in the introduction section, the selection of appropriate classifier for a particular task is a vital part.ANN has become a state of the art choice as nonlinear classifier in recent times due to available improved computing and parallel processing capabilities.We opted two state-of-theart non-linear classifiers: ANN and SVM for this classification task.The specifications and application details for each of the classifiers are described in the following subsections.

A. Artificial Neural Network
Artificial neural networks are the computing systems, composed of large number of highly inter-connected units (called neurons) that emulate the structure and operation of biological nervous system.There are many types and architectures of neural networks, fundamentally depending on their learning mechanisms.Multilayer Perceptrons (MLPs), also called Multilayer Feed Forward Neural network (MFNN) has an architecture comprised of an input layer, one or more hidden layers and an output layer.Typically, a MFNN with one hidden layer is sufficient to map any kind of linear or nonlinear approximation.An example of three-layer neural network architecture is shown in Fig. 7.An MLP operates in two phases: learning and recall.For the learning of MLP,   [12].There are many types of BP algorithm available, and it is desired to select one which best fit the data.We employed the Levenberg-Marquardt (LM) algorithm for the learning [34].It was designed to come up to second order training speed without computing the Hessian matrix.The Hessian matrix can be calculated as H=J T J, and the gradient can be computed as G=J T e.Where J is the Jacobian matrix, which contains the first derivatives of network error, and e is the network errors vector.
The iterative update in the weights incorporated by the LM algorithm is calculated as ) Where w represents the network weights, α is the learning parameter and I is the identity matrix.A large value of α corresponds to smaller step size in gradient descent approximation and vice versa.It was fixed as 0.9.
For the network training, the above procedure is followed.We selected an MLP with one hidden layer.To estimate the optimized number of hidden layer neurons, we used the crossvalidation data.For each of organized feature set as described in Tab. 2, the size of hidden layer is varied, and network performance is repeatedly observed against cross-validation error.The network configuration with the best cross-validation outcome is selected for classification of test data.Table 3 represents the estimated MLP architectures for different feature sets.The number of epochs for training was limited to 100.It was approximated after performing several training sessions.

B. Support Vector Machines
Support Vector Machines (SVM) is a widely used technique which involves supervised learning for binary classification.In this technique, a learning algorithm estimates a plane which separates the data between different classes.SVM have been employed both for linear and non-linear classification problems.It is worth repeating basic concepts of SVM classifier here.For the training data (x 1 , y 1 ), (x 2 , y 2 ), ……,(x n , y n ) with x i as feature vector of ith sample and y i as the corresponding target class, a linear SVM hyper plane fulfills the following conditions; 1 1 x w b for y x w b for y Where w represents the weight vector associated with x i and b represents the bias value.
In the case of two classes which are linearly non-separable, a suitable function (kernel) is used to transform the input feature space X into another feature space L (L = ƒ{X}), where it is possible to separate the classes linearly.Figure 8a shows linearly separable data with the hyper planes separating the classes with different margins.Non-separable data can be mapped by a mapping function to higher feature space, and can be separated by a linear hyper plane as shown in Fig. 8b [35].
For the purpose of visualization, we applied Principal Component Analysis (PCA) [36].PCA is primarily used for data representation in a lower dimension.The first principal component holds maximum variance among features.The second principal component holds the second highest variance and so on.We used first two principal components to produce the features representing data samples (holds ~70 % of the variance of original data).It was observed that the data is not separable in original feature space (the data plots can be seen in figures referred in results section).To classify the data with SVM, we transformed the input feature space to another feature space using Gaussian kernel function given as: Where σ is the scaling factor in kernel function Training data is used to train the SVM classifier.After training, the classifier is optimized by using the cross validation data.Two variables were selected to optimize the classifier's performance on cross-validation data: scaling factor of the kernel function "σ", and "C" to control the soft margin between classes and the hyper plane.We geometrically varied the values for these parameters such that each value for σ is tested in combination with each value of C. Following is the batch represents the options to select the value of these parameters; Batch = {.01 .02.05.08 .1 .2.4.6 .8 1 1.2 1.5 1.8 2 5 10 15 20 30 40 50 70 80 100} (9) The classifier is optimized by using the cross-validation data, in the following three ways independently:

V. PERFORMANCE EVALUATION
Since this is a binary classification task: the data is labeled as one of two categories: image sample of healthy nut (referred as Negative example) and image sample of unhealthy nut (referred as Positive examples).77 percent of the database is composed of negative examples (631 samples), while the rest 23% (187 samples) of images belong to positive examples.To be used with the classifier, the data of each class is divided as: 70% for training purpose, 15% for cross validation and 15% for test purpose.Training data is used to train the classifier, cross validation data is dedicated to optimize the classifier, and results are calculated on test (unseen) data.To ensure the generalized performance of classifiers, they were trained using randomly selected data.For each set of input features, we rotated the data five times in all three divisions: training, validation and test data.Finally an average of five outcomes of test data is calculated and presented as classification results.
The performance is evaluated regarding parameters defined as; Accuracy: the proportion of true results (both true positives and true negatives) in the total samples.Specificity: (or true negative ratio) probability of ingredient recognized as healthy, given that the ingredient was healthy Sensitivity: (or true positive ratio) probability of ingredient recognized as unhealthy, given that the ingredient was unhealthy These are calculated as:

RESULTS AND DISCUSSION
The two classifiers after being optimized by using the cross validation data were used to classify the test data.Their performance is evaluated and discussed in the following section.

A. Artificial Neural Network
Initially, ANN classifier is used for performance evaluation by using each of the organized set of features.At first, global texture statistical features (set 1) are fed to ANN, and results are produced.On average, the network demonstrated 81.8% classification accuracy, with 94.26% correct recognition of healthy nuts.However, the sensitivity rate was less than 50%, which is insufficient.Next, feature set 2 is fed at input layer of its corresponding estimated ANN architecture.The network showed a slight improvement in accuracy, less than 1%.On the contrary, recognition of unhealthy nuts is improved by 13.4%, and so the accuracy was compromised by comparatively lower specificity rate of 89.9%.Texture features from GLCMs (set 2) showed improved performance in recognizing unhealthy nuts, which is desired, but at the same time the size of this feature set -2.6 times larger than set 1 -is noticeable.Next, the combination of global statistical features and texture features from GLCMs (set 3) is used in order to seek improved network performance.The network with these features showed enhanced performance than previous outcomes.It showed 59.8% and 92% specificity and sensitivity rate respectively.Hence this combination of features has increased the classification accuracy -83.7% -but still unsuccessful in achieving a significantly good recognition rate for bad nuts.Feature set 4, which primarily projects the texture statistical characteristics of images and sounds a comprehensively superior choice of features, is then used with ANN.As a result, overall 84.5% accuracy is achieved and 93.28% healthy nuts were correctly identified.Unexpectedly, the sensitivity rate is even lower than the last outcome (since texture statistical features (set 1) seem having more significant information than simple statistical properties (set 3)).Next, we selected feature set 5 (contains all kinds of features extracted from test data) and fed to its corresponding estimated (trained and optimized) ANN architecture.The classification accuracy produced by the network using all the features was 87.6%, with 94.46% correct recognition of healthy nuts.62% of unhealthy nuts were correctly recognized which was the highest percentage of its kind so far.Hence using feature set 5, the network outperformed all previous outcomes on each evaluation parameter.
The key task in such a binary classification problems is to achieve the good recognition rate for unhealthy nuts while a minor rejection rate of healthy nuts is acceptable.It can be noticed by and large that taking into account the enlarging in feature set on size and information, the progress in classification accuracy is relatively not promising.Keeping this in mind, we tried to estimate a smaller feature set which yet is capable of providing the comparable results as obtained earlier with improved computational efficiency.It can be fairly expected that a small number of significant features may reflect comparable classification results.For this purpose, we selected eight texture statistical features from GLCMs calculated at an angle of 0° and 45°, and, also, four on the global level.These are combined and formed as the feature set 6, which is then fed to the network of its corresponding estimated architecture (see Tab. 3), and results are calculated.The network demonstrated the classification accuracy of 83.9%, as 3.74% less than reported using feature set 5. 90.7 percent specificity rate is achieved which is 3.72% Less than that of obtained by set 5. On the contrary, the true positive rate (sensitivity) is closer, with a difference of 1.32%.
In general, ANN classifier showed good recognition rate for healthy nuts, but the overall accuracy is poor due to meager performance of the network toward identifying the unhealthy nuts.It is observed that the classifier showed comparable results by feature sets 5 and 6.Hence a trade is perceivable between accuracy and the computational pace.Consequently by using feature set 6 (having less than 50% of information as compared to set 5), the computational efficiency can doubled in terms of feature extraction, and as a whole resulting in more computationally efficient network with small architecture.In this case, less than 2% sensitivity, 3.7% of specificity rate and overall 3.7% accuracy is compromised.Region Operative Characteristic (ROC) curves plotted for test data and total data with different choice of feature sets are shown in Fig. 9.

B. Support Vector Machine
Next we present the performance evaluation of SVM classifier by using different features (as given in Tab. 2) on the test data.As mentioned in section 4.2, the classifier was optimized on cross-validation data in three ways: for best classification accuracy, for best sensitivity, and for best tradeoff between Specificity and sensitivity.Note that the SVM classifier was trained using training data, optimized on validation data with the appropriate choice of σ (the scaling factor in Gaussian radial basis function kernel) and C (estimate of the soft margin between the classes), and later tested by using the test data.During optimization process using crossvalidation data, it was first optimized for overall accuracy so as to estimate the General performance of the classifier.Secondly, it was optimized to achieve highest sensitivity rate (considering the fact that recognition rate for the unhealthy nut is most important).Finally, it was optimized to achieve maximum sensitivity rate while maintaining a possibly fair specificity rate.These three-way optimizations were achieved by varying the parameters σ and C. The vector having choices of each of these parameters is given in (9).Individually, we employed the feature combinations (sets) given in Tab. 2, and calculated the results by using the test data as well as total data.As stated in section 4.2, to visualize the data separation performed by the classifier hyper plane, we applied PCA to each of feature sets.From each of feature sets, after applying PCA, first two principal components were used as features to represent each example.These features were then used with their corresponding optimized SVM classifier model.The hyperplanes separating the classes, estimated by the classifier optimized for overall best accuracy, are shown in Fig. 10 for different choice of features sets.Similarly, Fig. 11 represents the data separation with hyperplanes created by the classifier optimized for achieving maximum sensitivity rate.The classifier optimized for achieving best trade-off between recognition rate for healthy and unhealthy nuts, separated the data by the hyperplanes shown in Fig. 12 for different feature sets.The results produced by SVM classifier for the test data are summarized in Tab. 4. Considering all-purpose performance, the classifier produced best results with the choice of feature set 5. The classification accuracy equal to 88.9% is achieved having 94.3% and 77.6% correct recognition rate for healthy and unhealthy nuts respectively.On the contrary, if the focus is dedicated towards achieving highest sensitivity rate i.e. by using the optimized classifier for achieving maximum sensitivity, 100% unhealthy nuts can be identified.However, with this model more than 50% of healthy nuts are discarded, which are a huge figure and not a choice.Hence, it is necessary to optimize the classifier fair enough for both the target classes, while being generous towards achieving sensitivity rate.So the best result of SVM classifier considering both the true negative and the true positive rate is achieved when it is optimized for estimating best trade-off between specificity and sensitivity.Using feature set 5, 89.28% Unhealthy nuts were correctly identified while 86.3% healthy nuts were correctly spotted.Figure 13 presents the test data results calculated by three-way optimized classifier.
Comparing the two classifiers regarding individual evaluation parameters, ANN showed good performance in recognizing healthy nuts while SVM demonstrated the true positive ratio relatively better than that of produced by ANN.The finest performance was achieved with the choice of all extracted features (set 5) for both the classifiers.The relative improvement in accuracy was higher in the SVM case while choosing different features sets.The feature set 6 was estimated containing fewer significant features, to estimate a computationally efficient classifier.SVM proved to be the better choice as a classifier with this set showing 25% higher accuracy for recognizing unhealthy nuts, although the overall accuracy is similar for both classifiers.The comparative results for ANN and SVM with the best trade-off model is given in Tab. 5.
As discussed in the introduction section, pine nuts are rarely reported as the ingredient for quality inspection task.In contrast, pistachio is generally used in studies where nuts are used as ingredients for the quality assessment task.A comparison of results from studies where nuts are inspected as the ingredient is presented in Tab. 6.The table also presents the results of our previous study with pine nuts where a similar but much smaller database of x-ray images was used [37].

VII. CONCLUSION
In this article, binary classification of pine nuts using x-ray Images were presented.X-ray images were obtained by using a commercial x-ray machine on an experimental basis, and later each nut image was labeled by careful manual inspection.Image processing techniques were employed to develop a method which is capable to individually identify and extract the nuts when captured while moving on feeding belt.For features, statistical texture properties were calculated from image samples on the global level as well from co-occurrence matrices.Features were organized in different combinations to estimate their effectiveness for classification.Two state of the art non-linear classifier: ANN and SVM were used for classification.Classifiers were trained on training data, and optimized using cross validation data.The results were calculated on test data in different scenarios with different variants of features.On the whole, SVM performed better by achieving higher recognition rate for unhealthy nuts, while showing similar level of overall accuracy as demonstrated by ANN classifier.

Fig. 1 .
Fig. 1.Proposed schematic setup for selection of nuts with the aid of in-line quality assessment system

Fig. 3 .
Fig. 3. Image processing steps: from captured collective image to individual nut sample image (a) A sample sub-image (b) negative transformed image (c) binary image after the region of interest based thresholding (d) region detection with marked centroids (e) Regions detection after applying a 5×5 median filter mask (f) Regions detection after applying area threshold (g) True nutmeat region extraction (by cropping) from source image by using respective bounding boxes

Fig. 4 .
Fig. 4. X-ray image samples of Healthy and Unhealthy pine nuts III.FEATURE SELECTION

Fig. 5 .
Fig. 5. Position operator to calculate Gray Level Co-occurrence Matrix (GLCM) with angles and offsets A GLCM for an image I of size m×n is calculated as follows

Fig. 6 .
Fig. 6.Flow chart of proposed quality inspection systemspecial training algorithms have developed based on the learning rules similar to learning mechanisms of biological systems.By using the training data having inputs and corresponding targets, the weights of the classifier associated with the inputs are updated iteratively by the learning algorithm to approximate the target behavior.Back Propagation (BP) algorithm is typically used to update the weights, by minimizing the error function[12].There are many types of BP algorithm available, and it is desired to select one which best fit the data.We employed the Levenberg-Marquardt (LM) algorithm for the learning[34].It was designed to come up to second order training speed without computing the

Fig. 7 .
Fig. 7.A typical three layered artificial neural network architecture

Fig. 8 .
Fig. 8. (a) Left: Example of a linear discriminant analysis using SVM algorithm.Three hyperplanes are shown: π1 does not separate the two classes, π2 separates the two classes with a small margin and π3 corresponds to the best separating hyperplane.Right: Illustration of canonical hyperplanes (black dashed lines), the support vectors in magenta color and the distance between support vectors and best separating hyperplane ξ.(b) Left: Samples which are not linearly separable.Right: Non-linear data mapped to another feature space using the function Ф where linear separation is achievable • Achieving overall best classification accuracy regardless of individual class accuracy • Achieving the maximum sensitivity regardless of specificity or classification accuracy • Achieving best trade-off between specificity and sensitivity while prioritizing the sensitivity Later with each of the optimized classifier's model, test data is classified and results are recorded.The parameters accuracy, sensitivity and specificity are defined in the following section.
TP is equal to total number of true positives: the sample is an Unhealthy nut AND the classifier correctly classifies it as Unhealthy FN is the total number of false negatives: the sample is an Unhealthy nut BUT the classifier incorrectly classifies it as Healthy nut TN is the total number of true negatives: the sample is a Healthy nut AND the classifier correctly classifies it as Healthy nut FP is the total number of false positives: the sample is a Healthy nut BUT the classifier correctly classifies it as Unhealthy nut VI.

Fig. 9 .
Fig. 9. Receiver Operative Characteristic (ROC) curves produced by artificial neural network classifier for test data as well as total data using different feature sets

Fig. 13 .
Fig. 13.Comparative test data results produced by SVM models optimized on cross validation data for best accuracy, best sensitivity, and best trade-off.

TABLE I .
STATISTICAL AND TEXTURE STATISTICAL FEATURE EXTRACTED FROM X-RAY IMAGE SAMPLES ON GLOBAL LEVEL

TABLE II .
STATISTICAL AND TEXTURE STATISTICAL FEATURE EXTRACTED FROM X-RAY IMAGE SAMPLES ON GLOBAL LEVEL

TABLE III .
OPTIMIZED ARTIFICIAL NEURAL NETWORK ARCHITECTURES ESTIMATED FOR DIFFERENT SET OF FEATURES

TABLE IV .
CLASSIFICATION RESULTS OF TEST DATA PRODUCED BY DIFFERENT MODELS OF SUPPORT VECTOR MACHINE CLASSIFIER, ESTIMATED AND OPTIMIZED USING CROSS-VALIDATION DATA FOR ACHIEVING (A) BEST ACCURACY (B) HIGHEST SENSITIVITY RATE (C) BEST TRADE-OFF BETWEEN SPECIFICITY AND SENSITIVITY

TABLE V .
TEST SET RESULTS OBTAINED USING ARTIFICIAL NEURAL NETWORK AND SUPPORT VECTOR MACHINE (WITH BEST TRADE-OFF OPTIMIZATION)

TABLE VI .
RELATIVE COMPARISON OF RESULTS WITH OTHER INGREDIENT STUDIES