Abstract
In order to find the moldy maize kernels quickly, a method based on machine vision was proposed in this paper. Firstly, images of maize kernels were taken by the moldy maize sorting equipment, and three parts of every kernel, that is, moldy plaques, healthy endosperm and healthy embryo, were selected from these images. Then a threshold was set in R channel by analyzing color features of those three parts in RGB model. In this method, moldy plaques can be identified roughly. After that the location of the moldy plaques on the kernels was studied, a circle, whose centre was approximately the centroid of a maize kernel and diameter was about the width of embryos, was set to exclude the interference caused by shadow. This method, with the accuracy of 92.1%, laid a good foundation for the further study of moldy maize sorting equipment.
1. Introduction
Maize is widely grown throughout the world and plays an important role in the economy. It is also a vital source of energy, widely used as human food, alcohol fermentation, and animal feed [1, 2].
On the farm as well as in the storage, maize may be infected by molds under high temperature and humidity condition [3]. And these molds can cause damaging changes in both appearance and quality [4]. Some molds can also produce mycotoxins such as aflatoxin, fumonisins, and zearalenone, which are poisonous to humans and animals. The presence of molds and mycotoxins leads to price discounts or rejections by buyers, thereby greatly reduces the economic value of the product, and even brings about food safety issues [5]. The timely selection of moldy maize kernels not only can be useful to prevent the economic loss but also protect the safety of the food chain [6].
Nowadays, many methods have been used to detect moldy kernels; among them computer vision technology can get the target information in real time and it is rapid, accurate, and nondestructive [7]. At present, it has been widely used in food detection [8], such as food quality classification and food safety detection. Pearson et al. have developed a classifier by imaging algorithms which can classify normal pistachio, pistachios with oily or dark stains, and pistachios having kernel defects [9]. Mery et al. have developed a computer vision framework to automatically classify the quality of corn tortillas according to the geometric and color features [10]. Yorulmaz et al. detected popcorn kernels infected by the blue-eye fungus by image property covariance features [5]. Cao et al. applied machine vision technology to the diagnosis of maize disease [11]. Chen et al. use the color and veins feature to recognize moldy peanuts [12].
It is known that the color will change when kernels infected molds, so color is an important feature in detecting moldy grains.
The objective of this research was to achieve rapid and dynamic detection of moldy maize kernels by analyzing the color and texture features of maize kernels damaged by mold in different levels.
2. Material and Methods
2.1. Samples Preparation
In this study, 360 maize kernels were collected from filed-grown Yuyu corn in Hefei, Anhui Province, China. They were harvested in 2010 and some of them were damaged by mold during harvesting and storage.
The kernels were divided into three groups based on external appearance features.
Asymptomatic group: kernels in this group are evenly rounded, bright yellow-white, and there are no damage, bites, and visual mold.
Moderately moldy group: the samples are slightly discolored and there were tiny black or green plaques on the embryo.
Heavily moldy group: the maize kernels in this group are all with severely color change, and plaques covered the entire kernel surface. Kernels looked like even wizened.
The representative samples in each group are shown in Figure 1. The three sets of kernels were put in sealing bags separately and stored in a dry and ventilated environment to prevent further mildewing.

Maize kernel samples.
2.2. Single-Kernel Image Acquisition
Single-kernel images were taken by a maize sorting equipment invented by our group as shown in Figure 2(a). In this equipment a vibratory feeder (F-TO-C, FMC-Syntron, Homer City, PA) with a flat trough was attached with the conveying chute, an area CCD (DFK23G618, The Imaging Source, Germany) with a 12-mm lens (AZURE-1214MM, Fuzhou, China) was fixed perpendicular to the chute and interfaced with a computer by a Gigabit Ethernet line, a through-beam photoelectric switch was mounted on the end of the chute, and 3 nozzles were connected to air compressor by pipe and they were fixed under the chute and aimed at the groove in the chute. The working process of the equipment was illustrated in Figure 2(b).

The moldy maize sorting equipment.
By the reciprocating of feeder, maize kernels slide off the chute one after another, and at the end of the chute the kernels trigger the camera to acquire current images by blocking the photoelectric switch. The image resolution is 640 × 480 pixels.
2.3. Image Processing
The images of every kernel taken by the CCD were taken as processing targets of the sorting equipment. In order to sort maize kernel one by one, a fast image processing speed was needed. For every kernel image, the large area of background will inevitably increase the amount of calculation; thus, it would be better to remove that background information.
In this experiment, all the kernels slid down from the same chute and triggered the camera at the end of the sliding. As a result, these kernels in pictures were almost at the same position. Therefore, in order to reduce computational effort, a 250 × 250-pixel region of interest was enough and extracted from each image. The whole detection procedure for moldy maize kernels was shown in Figure 3.

The overall procedure for moldy maize kernels detection.
2.3.1. Color Feature Extraction
On moldy kernels, commonly there were tiny black or green plaques on the embryo. So the color features of the moldy plaques, health endosperm, and health embryos were conducive to be used to identify the moldy kernels. Both healthy endosperm and embryo blocks were extracted from 100 healthy kernel images; moldy blocks were also extracted from 100 moldy kernel images. After that, the average pixel value of R, G, and B channel in the RGB model for each block was calculated [13]. The pixel value distributions of the 3 parts, that is, moldy plaques, health endosperm, and health embryos, for every color channel were shown in Figure 4(a)–4(c).

Distribution of average pixel values for 3 groups of blocks.
The RGB model shown in Figure 4 indicated that the average pixel value of these three kinds of blocks in R, G, and B channel was similar. In R channel, the moldy plaques can be separated from healthy endosperm and embryo clearly, while the healthy endosperm and embryo were mixed; in G channel, healthy endosperm and moldy plaques had certain differences, but the pixel value of moldy plaques and healthy endosperm was distributed from 50 to 130 and from 100 to 170, so it is not easy to the separate moldy plaques from the health blocks; furthermore, in B channel three blocks were mixed seriously. So only the thresholds set in R channel can meet the requirement for detecting the moldy maize kernels. The average pixel value of moldy plaques varied from 50 to 120, so the thresholds were set according to (1), and the corresponding results were shown in Figure 5:

The processing results.
2.3.2. Position Identification of Moldy Spot
In the sample images, there was shadow at the edge of the kernels, which was caused by lighting. The color feature of that shadow is similar to the moldy plaques, so the shadow of the kernel edge and moldy plaques would be surely extracted by the thresholds set in R channel. Since the mildew spot appears mainly on the embryo, where it is roughly the middle part of the kernel, the identification of moldy spot position will help to reduce the interference of the shadow.
In order to count the moldy plaques position [14], 100 kernels were selected randomly from the moldy samples, and the width of embryos was measured. According to the statistics, the mildew spot mainly existed within a circle whose centre was approximately the centroid of a maize kernel and whose diameter was about the width of embryos. As shown in Figure 6, after preprocessing, binary images were got. Then dilation and erosion method were used to reduce noise. The centroid was found according to (2), and according to statistics, the radius of the circle was about 30 pixels. If there were black pixels within the circle, we treated the kernel as moldy kernel and, conversely, treated it as health kernel. The identification result was shown in Figure 7:

The centroid and radius of the circle.

The identification result.
3. Result and Discussion
In order to further verify the applicability of this method, 120 healthy kernels and 120 moldy kernels were selected; they were imaged by the moldy maize sorting equipment with their embryo sides facing up and processed by the method mentioned in this paper. The result was shown in Table 1.
Statistical results of detection.
As the result indicated, this method had a high accuracy in identifying the moldy kernels. However, because the kernels’ surface was not flat; thus there was shadow on the images, especially the color feature of the shadow and moldy plaques were similar. Also the diversification of the kernel shape and the limitations of statistical information of moldy plaques position all may lead to misjudgment.
This method can complete the detection of each kernel in about 87 ms, and it meets the rapid identification requirement of moldy maize kernels basically. However, in order to meet the requirement of online testing and to improve the detection accuracy in our future work, the comparison between the germ side and the reverse side of the kernel should be analyzed.
4. Conclusion
In this paper, the feasibility of detecting moldy kernels based on machine vision technology was verified.
Particularly, the different color feature of moldy plaques, healthy endosperm, and embryo was analyzed. The feature of moldy plaques on the kernels in R channel can be extracted easily and the identification of specific circle whose center was the centroid of the maize kernel was helpful to improve the detection accuracy.
The results show that, based on the method, about 18 kg kernels per chute can be detected using the equipment developed in an hour, and an accuracy of 92.1% can be achieved, which laid a good foundation for the further improvement of moldy maize sorting equipment.
Conflict of Interests
The authors declare that there is no conflict of interests regarding the publication of this paper.
Footnotes
Acknowledgments
This work was supported by the China National Science and Technology Support Program (Grant no. 2012BAK08B04).
