The use of vision techniques for the evaluation of selected quality parameters of maize grain during storage

. The paper presents an innovative method based on vision techniques for rapid assessment of contamination in the mass of stored maize grain. The research was carried out in a selected grain warehouse in the Opolskie Province. Maize grain was used in the studies, which was subjected to tests based on computer image analysis. To assess the state of maize grain contamination, a proprietary computer application based on the RGB model was used.


Introduction
The evaluation of quality characteristics is increasingly important due to the need to establish the purchase price and to ensure the continued use of seeds. An important problem of modern sustainable agriculture is the production of seeds and products with appropriate quality parameters. The research conducted so far shows that both the technology of harvesting, transport and drying conditions as well as storage have an impact on the quality of seeds, conditioning their suitability for the industry. The smallest irregularities may cause irreversible changes and significantly reduce the technological value of seeds and their processing products. In addition to processing, the cereal industry is also responsible for ensuring adequate protection during storage in order to preserve the properties and taste of the seeds. To achieve such an effect, the industry has a number of technologies and processes at its disposal. In some cases, and using the wrong parameters of these processes, the raw materials may change their quality characteristics, which will affect the final product. Therefore, it is important to continuously monitor the quality of raw materials and food products during storage, warehousing and heat treatment. The necessity of introducing continuous monitoring programmes for the evaluation of the quality of products and raw materials also results from the increasing consumer demands. According to official reports, 20% of the world's cereal harvest is destroyed by inappropriate storage conditions. The main causes of losses are: metabolism of seeds, activity of cereal pests, improper storage conditions and transport. Undoubtedly, such modern techniques include computer image analysis [8,9] The use of assistive tools allows to detect and highlight the elements of the image so that it becomes clear to the human eye. Computer image analysis uses many, often complex and abstract, repetitive transformations that can be repeated many times. Computer analysis is used to extract important information from the image [3].
In conclusion, it can be said that the evaluation of products, with particular reference to the qualitative characteristics taken into account in the commercial evaluation, plays an important role as it affects price and customer satisfaction. The development of a fast and effective method is definitely justified, as it will allow for accurate and quick observations without the additional use of complicated laboratory methods. Computer image analysis has a huge potential in the food industry and agriculture.

Purpose and scope of work
The aim of the study was to develop a fast method for the assessment of contamination in the mass of stored maize grain based on vision methods. A proprietary computer application was used to assess the condition of maize grain. The scope of work included: -development of a computer application for assessing the condition of maize grain in a warehouse with respect to biological contaminants, -performing an experiment in a grain warehouse, -selecting an appropriate sampling method, -statistical analysis of the obtained results.

Test Methodology
The research was conducted on the premises of the "Agropol" company in Łosiów. The grain of maize stored in grain warehouses with a usable area of 1217.3 m 2 , 885 m 2 and 1173 m 2 was studied. The total area of the facility is 8.6139 ha. On its premises there is an office building with a boiler room and a server room, a welfare building, a mechanical workshop, a laboratory building, grain warehouses (10 objects), a fertilizer warehouse, a commercial building, tractor shelters, as well as agricultural machinery and equipment and grain silos.
The grain warehouses were built in 2011. They have a steel structure, concrete foundations, reinforced concrete footings, external walls with elements of corrugated sheet metal, cast concrete floors. Sliding gates of the warehouses are made of corrugated sheet metal. The roof is pitched, has a steel structure with lattice girders and is covered with trapezoidal sheet metal.
The use of image analysis to study the quality characteristics of agri-food products is not a new approach. The main advantage of this method is its extraordinary accuracy and repeatability. The method, however, requires a lot of effort in terms of image acquisition conditions. The most important factor is lighting conditions, both in terms of colour temperature as well as intensity. It is also crucial to arrange the light source correctly so that the tested object is illuminated evenly, with as little shadows and reflections as possible. In terms of preparation of the image acquisition stand, it was decided to adopt a compact solution, i.e. allowing the observation of objects with a maximum size of 20 x 20 cm.
Elements of the image acquisition stand: -closed chamber, -LED lighting system, -5 Mpx image acquisition system ( Fig. 1) The proposed method is based on the automatic analysis of images. In this context, a number of fundamental research issues where graphic images are the input information should be considered. The first stage is to define the goal of research and to select methods and tools to support its implementation. In this respect it has been specified that the parameters of the grain (sample) collection will be determined, which will then be used to assess its quality. The focus was on two types of parameters. The first group includes parameters based on the analysis of the distribution of colours on the surface of the tested object (sample). It should be noted here that studies in which the distribution of colours in the sample was used are known, and they mainly concerned the determination of the proportion of different cereals in heterogeneous mixtures [6,7]. The second group consists of morphological features possible to obtain for single objects in the sample, i.e. grains.
The acquisition of images is the first stage of the proposed method and it is an operation involving the introduction of a digital representation of the examined object into a computer system. The most common method is to use visible (light) radiation to illuminate the sample and to detect reflected light by means of a suitable sensor. It is worth emphasizing here the need to be careful and respect the principles of correct acquisition of graphic images. This applies in particular to the proper illumination of the sample, i.e. where the luminous intensities, the inclination angle of the rays incident on the sample and the spectral temperature of the light are correctly chosen. Possible mistakes made at this stage cause significant problems in terms of correctness of measurement and the amount of information that can be obtained from the image. In particular, attention should be paid to the repeatability of the measurement, which is of key importance for the presented method and is an absolute condition for the metrological correctness of the measurements performed. Consideration should also be given to optimum use of the brightness ranges of the light sensor so that the resulting image has the highest possible ratio of use of all brightness levels for achromatic images and levels of intensity of RGB components for chromatic images. It is very important that the illuminated sample does not generate additional artifacts such as shadows or areas of increased brightness (impasto), which during the analysis may disturb the image and suggest the existence of additional elements or distort the shape of the observed object. In the aspect of shadows, multipoint lighting with diffuse light and as high as possible distribution of light sources within the whole observed area is proposed [8].
After the acquisition, the image needs to be processed. Image processing is an operation in which there is an image at both input and output. A processing operation can be performed for a number of reasons. In the discussed issue one of the first steps is to process the image in order to remove any possible distortions [4]. These distortions may have manifold sources and various characteristics. The description of all potential distortions resulting from the imperfections of the acquisition method is beyond the scope of the present study. The basic task is to separate the examined object from the background. This operation is called segmentation. Due to the nature of the morphological analysis method [1,2] planned to be applied, the image will be binarised, i.e. transformed from a colour image into a binary one. In addition to the threshold method, the applied tool (APR), described in the following section, has an implemented segmentation algorithm that allows segmentation based on the selection of any number of areas. Each area is represented by a designated rectangle containing averaged pixels of all components. This creates a single pixel value as the basis for determining the colour distance between this pixel and all the pixels of the analysed area. The software allows to select the metric in which the distance is calculated, and after selecting it the image is automatically segmented into as many areas as there were reference areas assumed. After segmentation by simple methods available in APR, it is possible to remove all pixels except those with specific component values, and then binarisation will be performed. Thus processed image constitutes an input to the morphological analysis procedure [1,2]. In the first stage of distortion analysis, however, the focus was on verifying the shares of particular types of identified classes in the sample images. 3 classes were identified for maize sample: background (omitted in the analysis), grain (with possible breakdown into characteristic elements such as furrow, etc.), artifacts.
The developed application is used to analyse, process and recognise images. Its basic feature is the ability to build image processing scripts. For this purpose, a scripting language has been built in to allow a number of graphical operations. In addition, it is possible to enter commands directly in the command line. Part of the operations is available from a panel containing an appropriate communication interface with the user. The main window of the application allows to work on multiple images in separate workspaces. Operations in each space can be performed independently from others using commands, scripts, or a helper panel that contains dialog items facilitating interaction with the program. Image windows have their own menus, bookmarks, information bar and help panel. After pressing the Save or Read Image button, the corresponding dialog box appears where you can select a file. The program is designed to read and write images in standard graphic formats (BMP, JPEG).
Scripts are the basic method used to process images in this application. Individual commands can also be given by entering them in the command line. The Lua language, a powerful scripting programming language, has been adopted to implement the program commands. The commands should be typed taking into account the name of the image to which they are to apply.
A number of mechanisms have been put in place to facilitate programming. One of them is the defaultness of certain parameters, which significantly shortens the time of writing scripts.
The commands of basic and advanced image processing are an integral part of the APR application, which includes, among others, specialized and unique proprietary solutions in the field of morphological analysis of the binary scene. The choice of APR was dictated by considerations of consistency with existing research and the efficiency of the tool. APR has interfaces that allow to create own functions in C++ language. APR is designed for computational performance and a strong focus on real-time applications. It is written in C++ language in a way that enables efficient analysis and processing of complex scenes and even video sequences.
As mentioned above, the main window of the program can contain several images. Operations on each image may be performed using commands, scripts, or an auxiliary panel that contains dialog items facilitating interaction with the program. Image windows have their own menus, bookmarks, information bar and help panel. After pressing the Save or Read Image button, the corresponding dialog box appears where you can select a file. The program is adapted to read and write images in BMP and JPG format. Scripts are the basic method used to process images in this application. Individual commands can also be given by entering them in the command line. The developed language has a number of commands which concern the handling of images (read, write, etc.), image processing and their analysis. The commands should be typed taking into account the name of the image to which they are to apply. A number of mechanisms have been put in place to facilitate programming. One of them is the defaultness of certain parameters, which significantly shortens the time of writing scripts.
The conducted experiment consisted of 10 series of tests, 50 samples each, in 3 repetitions consisting in the conventional evaluation of contamination in the mass of maize grain using the method of observation under a magnifying glass, a microscope and a weight-and-screen method (Fig. 2), and using a computer image analysis (Fig. 3    In addition, within the framework of conventional tests carried out to assess the quality of maize during storage, individual parameters were assessed, including: humidity, temperature, density. For the results obtained, a statistical analysis was carried out.

Analysis and discussion of results
On the basis of the obtained results of maize grain quality during storage, the following descriptive statistics were obtained (Table 1

Conclusions
The results obtained from conventional examinations of the quality of selected raw material parameters, such as: humidity, grain temperature, density in maize, present standardized results within the limits of established imperatives, which prove that the process of storage and warehousing of grain subjected to computer-assisted analysis is proceeding properly.
The results of further studies of grain quality computer analysis indicate that the adopted direction of research is promising. The biggest problem in examining the area share was the relatively low quality of the photos resulting from the adopted methodology, according to which the photos for this examination concerned a collective sample placed on a Petri dish. In developing the method, another solution should be adopted, in particular one in which the sample to be acquired contains at most one layer of grain placed on a contrasting background (preferably blue R0G0B255). Irrespective of these difficulties, a relatively small dispersion of the measured values could be observed for each of the grain types, i.e. maize. As regards the studies on grain morphology, the results should be considered satisfactory. At the same time, it should be noted that at present there are no standards or detailed studies concerning the unambiguous relation between the results of morphological analysis performed on the grain image and the evaluation of its quality. On the basis of the analysis of the results obtained for maize it can be concluded that the proposed use of standardised measures relating to symmetry and circularity of objects corresponds to the given problem, i.e. it allows for the study of homogeneity of grain shape in the sample.