Method for Detection of Wheat Grain Damage with Application of Neural Networks* Aleksander Kubiak1, Zbigniew Mikrut2 1 Food Engineering Department, University of Warmia and Mazury, Oczapowskiego 7, 10-725 Olsztyn, Poland e-mail: akubiak@uwm.edu.pl 2 Institute of Automatics, University of Mining and Metallurgy, Mickiewicza 30, 30-059 Kraków, Poland e-mail: zibi@biocyb.ia.agh.edu.pl Abstract. In the present paper the application of backpropagation type neural networks to assessment of wheat grain quality is described. The contours of whole and broken grains have been extracted using the log-polar transform, precisely normalised and then used as input data for the neural network. The network optimisation has been carried out and then the results have been analysed in the context of response values worked-out by the output neurones. By evaluation of the obtained results it has been found that correct recognition of the grain quality is possible on the 97% level for the learning set, and 94% level for the test set. The achieved recognition level allows the utilisation of the proposed method in industrial devices dedicated to grain quality evaluation. 1 Introduction The assessment of wheat grain quality is being done at all the stages of its production, processing and storage. Small grains and impurities are removed using mechanical sieves. Still such a procedure does not guarantee an efficient removal of all the broken grains. Considerable quantity of damaged grains in the wheat affects its quality as a seed, and also as a material for further processing. The quality evaluation of food and agricultural products is done mainly by their visual inspection, carried out by qualified experts. When analysis of huge number of samples is required such evaluation is expensive, time-consuming and subjective. Computer image analysis is one of the fields which enable an objective evaluation of grain materials. It has been applied for quality assessment of edible beans[1], rice [7], pistachio nuts [3] as well as wheat grain [4]. The classification systems used for qualitative evaluation of the examined samples are mainly based on the analysis of geometrical parameters of the studied objects (length, width, area, circumference, shape coefficients) [4]. Multidimensional databases describing * This work was partially supported by the University of Mining and Metallurgy grant No. 10.10.120.39. the shapes of the studied objects are used for classification based on statistical methods [6], fuzzy sets [1], genetic algorithms [2] and neural networks [3]. Taking into account the fact that the geometrical parameters used up to date do not fully reflect the shape of the studied objects, in the present work the log-polar transform [8] of the outlines of whole and broken grains has been used as a form of input data for the neural network. One version of the method (so called logHough transform) proved to be quite efficient as a preprocessing algorithm for shapes recognised by use of a Kohonen network [5]. In the present work backpropagation type networks have been used for the task of recognition of whole and broken wheat grains. 2 The Research Material and Preprocessing The research material consisted of samples of wheat grains (whole and broken), belonging to two wheat varieties: one Polish Gama variety and one German Estica variety. The grain images, registered using a CCD camera and an image acquisition module, have undergone preprocessing by binarisation, dilation, erosion and hole filling1. The binarised wheat grain images have been transformed to the logpolar representation and edge-detection has been carried out. The most important stage of the preliminary processing was a versatile normalisation of the grain image edges in the log-polar space. The well-known properties of replacement of rotation and magnification operations in the Cartesian space by translations along respective directions in the log-polar space has been used [10]. In particular [5]: the object has been centered by iterative calculation of the gravity centre the angular position has been normalised by analysis of edge function derivative, attenuated by exponential function the object's edge has been iteratively shifted along the "radius" axis, what is equivalent to magnification normalisation in the Cartesian space (see Fig. 1). The normalised vector representations of the studied wheat grains has been used as input data for a backpropagation type neural network, implemented using the NeuralWare Professional II+ software. The network's input data have been divided into two sets: the learning set consisting of a proportional number of the input data, representing both the whole and broken grains of both wheat varieties, and a test set, consisting of the remaining data (see Table 1). Taking into account the greater diversity of the broken grain shapes in relation to the whole grains, the vectors representing the broken grains of Estica variety have been placed twice in the learning sequence: in the beginning and in the middle, in order to achieve a better learning by the network. The learning sequence thus consisted of 500 data samples. For testing of the trained network both learning and test sets have been used, consisting of 400 and 513 elements respectively. 1 using the Lucia D ver.3.5 package (Laboratory Imaging Ltd., Prague, Czech Republic). Neural Network angle & zoom normalization edge detection centering binarization dilation & erosion hole filling Fig. 1. Upper row: preprocessing of the image of the whole grain in Cartesian space, below: normalisation in log-polar domain. Dimension of the log-polar images is 40x144 pixels. Table 1. Structure of the data in the learning and test sets Variety Estica Gama Total 3 Learning set Whole Broken 100 100 100 100 200 200 Test set Whole 48 189 237 Broken 185 128 313 Total Whole 148 289 437 Broken 285 228 513 Neural Network The neural network used in experiments consisted of 3 layers. The input layer was formed by 144 neurones, reflecting the number of the input vector components. The number of neurones in the hidden layer has been determined experimentally, by testing 80 networks of various number of elements in the hidden layer. The network's output layer consisted of two neurones, one for each class to be recognised (whole, broken). Consecutive network's learning cycles have been carried out for various values of the learning coefficients and the momentum parameter. For selected networks the learning process has been also carried out for vari- ous starting values of "random seed" parameter, which affects the selection sequence for presentations of the learning set elements. The best results have been obtained for a network containing 15 neurones in the hidden layer. The remaining parameters have been set as follows: learning rate for the hidden layer 0.3, learning rate for the output layer 0.15, the momentum parameter 0.3, Delta learning rule and sigmoidal transfer function. The number of presentations was set to 200000. 4 Results of the Study After completion of the learning process the neural network of the 144-15-2 structure has been tested - using both the learning and test sets. The learning set has been used in order to determine the reliability with which the network recognises the whole and broken grains used in the networks learning, and to propose some additional parameters which might be helpful in increasing the percent recognition level. The recognition results for the wheat grains have been analysed by two methods: "threshold" recognition: the output values produced by neurones of the network's output layer have been compared to a certain "threshold value". In the cases when the value of the neurone's answer has been greater than the threshold value the output values has been regarded as a correct recognition (otherwise it was regarded as a rejection) so called recognition reliability Delta [9] has been determined: the difference of the values produced by the output layer neurones has been calculated and then it was compared to a certain, predetermined value. In cases when the difference was greater than the given value the neurone's answer was taken into account, otherwise it was rejected. In the test carried out both methods of neurone response classification have been taken into account. Both threshold and difference values have been preliminarily determined from the intersection point of the cumulative histograms of individual neurone's responses for the learning set (Fig. 2). The recognition results for the learning and test sets for selected threshold and reliability values are presented in Tables 2,3. Table 2. Recognition results (%) for the learning set using threshold and difference (Delta) Thre- Reshold jected 0.4 0.00 0.5 0.00 0.6 0.25 0.7 2.25 0.8 5.00 0.9 11.00 Total Whole Broken 96.50 96.50 96.49 96.67 96.84 96.63 96.50 96.50 96.48 96.87 97.33 97.21 96.50 96.50 96.50 96.48 96.37 96.04 Delta Rejected 0.4 2.25 0.5 3.75 0.6 5.75 0.7 8.00 0.8 12.00 0.9 29.00 Total whole Broken 96.67 96.88 97.61 97.55 97.73 98.24 96.48 96.92 97.89 97.81 98.27 98.48 96.87 96.84 97.33 97.30 97.21 98.03 number of responses threshold*10 Fig. 2. Cumulative histograms of correct responses (solid line, cumulation from 1 to 10) and wrong ones (dotted line, cumulation from 10 to 1). Table 3. Recognition results (%) for the test set using threshold and difference (Delta) Threshold 0.4 0.5 0.6 0.7 0.8 0.9 5 Rejected 3.27 3.27 5.64 6.54 12.36 18.36 Total Whole Broken 92.10 92.10 93.06 93.38 94.19 94.88 86.58 86.58 88.00 88.51 89.71 90.73 100.00 100.00 100.00 100.00 100.00 100.00 Delta Rejected 0.4 4.36 0.5 7.45 0.6 10.54 0.7 12.54 0.8 16.90 0.9 33.64 Total Whole Broken 91.25 91.75 92.28 92.72 93.22 95.07 94.78 95.09 95.45 96.28 96.17 96.32 88.51 89.12 89.71 89.85 90.73 94.06 Discussion and Summary The recognition level for the learning set was 96%, while the network has recognised 96.5% of the whole grains and 95.5% of the broken grains. The recognition level for the test set was 89.1% total and 94.5% and 83.7% for the whole and broken grains respectively. From the results presented in Tables 2 and 3 it can be seen how grain quality recognition level for the learning set is changing depending on the threshold or Delta value. This was used to determine the threshold value as 0.8 and then the recognition level was found to be 96.4% and 97.3% for the whole and broken grains respectively. The results have been obtained with rather low percentage of rejection cases which was equal to 5%. For the same learning set a similar effects has been obtained for Delta value equal to 0.6 and then the recognition levels were 97.9% and 97.3% for the whole and broken grains respectively. For the test set the networks has recognised - for the same values of threshold and Delta values - 100% of the whole grains and 89.7% of broken grains for the threshold value equal to 0.8. For the Delta value equal to 0.6 the network has recognised correctly 95.4% and 89.7% of the whole and broken grains respectively. The rejection levels for the above mentioned threshold and Delta values were respectively 12.4% and 10.5%. By evaluation of the obtained results it has been found, that by making use of the threshold or Delta values it is possible to recognise correctly the wheat grain quality with recognition level exceeding 90% (94.2% for threshold value equal to 0.8 and 92.3% for Delta=0.6). In this application the above mentioned rejection rates are meaningless because during industrial testing we can easily resize the set of grains to be recognised. Taking into account the fact that in the research material two wheat varieties were present, often exhibiting quite considerable diversity within each wheat variety, and between the varieties, such a recognition level should be regarded as high, what makes a good prospect for application of the object edge normalisation method in the log-polar space and the neural networks in industrial devices for wheat grain quality assessment. References 1. Chtioui Y., Panigrahi, S., Backer L. F. (1999) Rough sets theory as a pattern classification tool for quality assessment of edible beans. Trans. of the ASAE, vol. 42(4):11451152 2. Chtioui Y., Bertrand D., Barba D. (1998) Feature selection by genetic algorithm. Application to seed discrimination by Artificial Vision. J. Sci. Food Agric, 76, 77-86 3. Ghazanfari. A., Irudayara J., Kusalik A. (1996) Grading pistachio nuts using neural network approach, Trans. of the ASAE, vol. 39(6):2319-2324 4. Kubiak A., Fornal Ł. (1994) Interaction between geometrical features and technological quality of polish wheat grain. Polish Journal of Food and Nutrition , 7/48, 3, 160-167 5. Mikrut Z. (2001) Recognition of objects normalised in Log-polar space using Kohonen networks. Proc. of the 2nd Int. Symp. Image and signal processing and analysis, Pula, Croatia 6. Ohsawa R., Tsutsumi T. H. et al. (1998) Quantitative evaluation of common buckwheat (Fagopyrum esculentum Moench) kernel shape by elliptic Fourier descriptor. Euphtica, 101, 175-183 7. Sakai N., Yonekawa S., Matsuzaki A. (1996) Two dimensional image analysis of the shape of rice and its application to separating Varieties. Journal of Food Engineering, 27, 397-407 8. Schwartz E. L. (1977) Spatial mapping in the primate sensory projection: analytic structure and the relevance to perception. Biological Cybernetics, 25, 181-194 9. Tadeusiewicz R., Mikrut Z. (1994) Neural Networks applied to visual pattern recognition – a comparative study. Appl. Math. and Comp. Sci., vol. 4 No. 3, 397-411 10. Weiman C. F. R. (1989) Polar exponential sensor arrays unify iconic and Hough space representation. SPIE vol. 1192: Intelligent robots and computer vision VIII