Corn kernel early mildew identification method based on OCT image
1. An OCT image-based early-stage mildew identification method for corn kernels is characterized by comprising the following steps:
1) acquiring an OCT (optical coherence tomography) seed image of corn seeds;
2) carrying out primary noise reduction on the OCT seed image to obtain the OCT seed image subjected to primary noise reduction;
3) after edge detection and boundary searching and fitting are carried out on the primary noise-reduced OCT grain image, a first boundary of a background and corn grains is obtained;
4) searching the highest point of a first boundary line of the background and the corn kernel, and carrying out flattening transformation on the primary noise-reduced OCT kernel image by taking the highest point of the first boundary line as a reference to obtain a flattened OCT kernel image;
5) taking a boundary in the flattened OCT seed image as a second boundary of the background and the corn seed, cutting the flattened OCT seed image by taking the second boundary as a reference, and cutting off an image of the endosperm of the lower half part according to the respective thicknesses of the peel, seed coat and aleurone layer of the known corn seed in the cutting process; meanwhile, a background area exceeding a preset distance of the second boundary in the upper half part is cut, and an OCT grain image after cutting is obtained;
6) extracting the boundary of the corn kernel pericarp and the seed coat;
7) calculating the average gray level of the boundary between the corn kernel peel and the seed coat, setting the pixel point which is smaller than the filtering threshold value in the cut OCT kernel image to be 0 by taking N times of the average gray level as the filtering threshold value, and obtaining the boundary between the corn kernel peel and the seed coat after filtering;
8) calculating the number of non-0 pixels in the current front row of pixels on the boundaries of the fruit skin and the seed skin of the filtered corn kernel by taking the row pixels as a unit, taking the number of the non-0 pixels in the current row of pixels as the array value of the current row, and traversing all rows of pixels to obtain a one-dimensional upper boundary array;
9) taking an array average value of the one-dimensional upper boundary array, and taking M times of the array average value as a discrimination threshold; comparing each array value in the one-dimensional upper boundary array with a discrimination threshold, and if the array value is greater than the discrimination threshold, indicating that an early mildew point exists in the row of pixel points where the array value is located; if the array value is less than or equal to the discrimination threshold, the array pixel point where the current array value is located does not have an early mildew point.
2. The OCT image-based corn kernel early mildew identification method of claim 1, wherein the OCT image-based corn kernel early mildew identification method comprises the following steps: the step 2) is specifically as follows:
determining a noise reduction threshold of a hard threshold filtering method according to the noise intensity of a background region in the OCT seed image, and carrying out primary noise reduction on the OCT seed image by using the hard threshold filtering method to obtain the primary noise-reduced OCT seed image.
3. The OCT image-based corn kernel early mildew identification method of claim 1, wherein the OCT image-based corn kernel early mildew identification method comprises the following steps: the step 3) is specifically as follows:
3.1) edge detection is realized on the primary noise-reduced OCT seed image by using an edge detection operator to obtain an edge-detected OCT seed image, and then template filtering processing and binarization processing are carried out on the primary noise-reduced OCT seed image to obtain a binarization seed image;
3.2) searching each row of pixel points in the binarized grain image from top to bottom for the pixel point with the first gray value of 1 in the current row of pixel points and recording the pixel point as a pixel point to be fitted;
3.3) traversing all rows of pixel points in the binarized grain image to obtain all pixel points to be fitted in the binarized grain image;
and 3.3) fitting all pixel points to be fitted by using a fitting method to obtain a first boundary line of the background and the corn grains.
4. The OCT image-based corn kernel early mildew identification method of claim 1, wherein the OCT image-based corn kernel early mildew identification method comprises the following steps: the step 6) is specifically as follows:
6.1) defining the correlation weight between two communicated pixel points according to the gray value of the pixel, wherein each pixel point is communicated with each adjacent pixel point; calculating the correlation Weight between two communicated pixel points by adopting the following formulaab:
Weightab=2.01-ga-gb
Wherein, gaAnd gbPixel gray values of two communicated pixel points a and b are respectively obtained;
6.2) calculating the gray value of each pixel point in the cut OCT seed image and carrying out normalization processing;
6.3) adding a plurality of rows of pixel points on the leftmost side and the rightmost side of the cut image respectively, wherein the associated weight of each two communicated pixel points in the leftmost row of pixels and the rightmost row of pixels is zero;
6.4) taking the middle pixel point of the leftmost column of pixel points as an initial point of boundary search, taking the middle pixel point of the rightmost column of pixel points as an end point of boundary search, and adopting a shortest path search algorithm by combining the communication condition and the associated weight of each pixel point in the image to obtain the initial upper boundary of the pericarp and the pericarp of the corn kernel;
6.5) smoothing the primary upper boundary of the corn kernel pericarp and the seed coat by using a smoothing algorithm to obtain the upper boundary of the corn kernel pericarp and the seed coat.
Background
Corn is one of the main grain crops in the world, is widely planted around the world, is used as grain by people and is also used as feed of various animals, and corn kernels are extremely easy to be polluted by toxic fungi under the condition of damp heat. The major secretion of mold, Aflatoxins (Aflatoxins), is a recognized harmful chronic mycotoxin and has a potentially important threat to food safety. Therefore, the method is necessary for the research of the rapid detection method of the aflatoxin in the corn kernels. Chemical methods are generally adopted in the experiment, including thin layer chromatography, high performance liquid chromatography, enzyme linked immunosorbent assay, polymerase chain reaction and the like, and rapid or on-site detection methods are more required in the food industry, and reference is made to the following methods: near infrared spectroscopy, raman spectroscopy, terahertz time-domain spectroscopy, and electronic noses. National standards in China all use chemical methods as reference standards, but due to the defects of time and labor waste, large pollution and the like of pretreatment, the method cannot be used for on-site rapid detection. Most spectroscopic-based methods measure the absorption of a sample directly at different wavelengths and the spectra extracted by chemometric methods vary little. The electronic nose device establishes an array of gas sensors for chemical targets, then converts the signals of the sensors into digital bits, and simultaneously captures the flavor characteristics of mold emissions in combination with chemometrics methods. The methods aim at signal or data processing and lack space or depth resolution, so that the realization of early diagnosis of the corn kernel mildew by the existing method is still difficult;
optical Coherence Tomography (OCT) is a tomographic technique that captures near-surface reflected light and reveals three-dimensional microstructures, and has the advantages of no damage, high resolution, high speed, and the like. Various reports have shown that internal 2D or 3D images of OCT technology can extract tissue or cellular information up to 2-3mm in depth at a resolution of 5-20 μm. The transmission depth, the resolution and the sensitivity of the method are superior to those of the traditional optical or imaging method, and the method can capture the mold spore form attached to the surface of corn kernels. However, the research is still in the initial stage for the early rapid detection of the mildew of the corn kernels.
Disclosure of Invention
Aiming at the problems in the background art, the invention aims to provide the corn kernel early mildew identification method based on the OCT image, which can automatically identify the early mildew of the corn kernel in the OCT image, complete the automatic identification and judgment of the mildew position, improve the detection efficiency, and lay the technical foundation for the online automatic detection of the corn kernel by matching with the appearance detection methods such as imaging and the like.
The technical scheme adopted by the invention comprises the following steps:
1) acquiring an OCT (optical coherence tomography) seed image of corn seeds;
2) carrying out primary noise reduction on the OCT seed image to obtain the OCT seed image subjected to primary noise reduction;
3) after edge detection and boundary searching and fitting are carried out on the primary noise-reduced OCT grain image, a first boundary of a background and corn grains is obtained;
4) searching the highest point of a first boundary line of the background and the corn kernel, and carrying out flattening transformation on the primary noise-reduced OCT kernel image by taking the highest point of the first boundary line as a reference to obtain a flattened OCT kernel image;
5) taking a boundary in the flattened OCT seed image as a second boundary of the background and the corn seed, cutting the flattened OCT seed image by taking the second boundary as a reference, and cutting off an image of the endosperm of the lower half part according to the respective thicknesses of the peel, seed coat and aleurone layer of the known corn seed in the cutting process; meanwhile, a background area exceeding a preset distance of the second boundary in the upper half part is cut, and an OCT grain image after cutting is obtained;
6) extracting the boundary of the corn kernel pericarp and the seed coat;
7) calculating the average gray level of the boundary between the corn kernel peel and the seed coat, setting the pixel point which is smaller than the filtering threshold value in the cut OCT kernel image to be 0 by taking N times of the average gray level as the filtering threshold value, and obtaining the boundary between the corn kernel peel and the seed coat after filtering;
8) calculating the number of non-0 pixels in the current front row of pixels on the boundaries of the fruit skin and the seed skin of the filtered corn kernel by taking the row pixels as a unit, taking the number of the non-0 pixels in the current row of pixels as the array value of the current row, and traversing all rows of pixels to obtain a one-dimensional upper boundary array;
9) taking an array average value of the one-dimensional upper boundary array, and taking M times of the array average value as a discrimination threshold; comparing each array value in the one-dimensional upper boundary array with a discrimination threshold, and if the array value is greater than the discrimination threshold, indicating that an early mildew point exists in the row of pixel points where the array value is located; if the array value is less than or equal to the discrimination threshold, indicating that no early mildew point exists in the column pixel point of the current array value;
the step 2) is specifically as follows:
determining a noise reduction threshold of a hard threshold filtering method according to the noise intensity of a background region in the OCT seed image, and carrying out primary noise reduction on the OCT seed image by using the hard threshold filtering method to obtain the primary noise-reduced OCT seed image.
The step 3) is specifically as follows:
3.1) edge detection is realized on the primary noise-reduced OCT seed image by using an edge detection operator to obtain an edge-detected OCT seed image, and then template filtering processing and binarization processing are carried out on the primary noise-reduced OCT seed image to obtain a binarization seed image;
3.2) searching each row of pixel points in the binarized grain image from top to bottom for the pixel point with the first gray value of 1 in the current row of pixel points and recording the pixel point as a pixel point to be fitted;
3.3) traversing all rows of pixel points in the binarized grain image to obtain all pixel points to be fitted in the binarized grain image;
and 3.3) fitting all pixel points to be fitted by using a fitting method to obtain a first boundary line of the background and the corn grains.
The step 6) is specifically as follows:
6.1) defining the correlation weight between two communicated pixel points according to the gray value of the pixel, wherein each pixel point is communicated with each adjacent pixel point; calculating the correlation Weight between two communicated pixel points by adopting the following formulaab:
Weightab=2.01-ga-gb
Wherein, gaAnd gbPixel gray values of two communicated pixel points a and b are respectively obtained;
6.2) calculating the gray value of each pixel point in the cut OCT seed image and carrying out normalization processing;
6.3) adding a plurality of rows of pixel points on the leftmost side and the rightmost side of the cut image respectively, wherein the associated weight of each two communicated pixel points in the leftmost row of pixels and the rightmost row of pixels is zero;
6.4) taking the middle pixel point of the leftmost column of pixel points as an initial point of boundary search, taking the middle pixel point of the rightmost column of pixel points as an end point of boundary search, and adopting a shortest path search algorithm by combining the communication condition and the associated weight of each pixel point in the image to obtain the initial upper boundary of the pericarp and the pericarp of the corn kernel;
6.5) smoothing the primary upper boundary of the corn kernel pericarp and the seed coat by using a smoothing algorithm to obtain the upper boundary of the corn kernel pericarp and the seed coat.
The invention has the beneficial effects that:
the invention uses the OCT image to detect the mildew of the corn kernels, and can detect the early mildew invisible to naked eyes because the resolution ratio of the OCT image can reach ten microns, thereby having the advantages of no damage, rapidness and low cost.
The method adopts an automatic image processing scheme, comprises a noise reduction process and a graph method boundary searching process, provides a corresponding weight strategy, has universality on early mildews of different shapes, sizes and stages, can automatically mark the position where the mildews occur, and has better positioning precision compared with other methods.
The invention always adopts the gray value as the evaluation parameter and combines with the image leveling, and the detection effect has certain robustness.
Drawings
FIG. 1 is a flow chart of the method of the present invention.
Fig. 2 is an OCT kernel image of a corn kernel collected.
Fig. 3 is a diagram illustrating the effect of the leveling step of the present invention.
Fig. 4 shows the result of clipping the image based on the boundary line in the embodiment.
FIG. 5 is a graph of the effect of an embodiment of automatic marking by a mildew location algorithm of one of the early mildew samples.
Detailed Description
The present invention will be described in further detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
The examples of the invention are as follows:
as shown in fig. 1, the present invention comprises the steps of:
1) using an OQ Labscope type SD-OCT imager to acquire OCT kernel images of 30 corn kernel samples, 15 of which contained early mildew and 15 were normal samples (control); fig. 2 is an OCT image of 2 typical samples, in which (a) of fig. 2 is a normal non-mold sample and (b) of fig. 2 is a sample in which various forms of mold exist.
2) Observing the data set of the 30 OCT grain images, finding an area in which the speckle noise is concentrated from the third row to the tenth row of the OCT grain images from top to bottom, calculating the mean value and the standard deviation of pixels in the area, and performing hard threshold noise reduction on the OCT grain images by taking the sum of the mean value and the standard deviation as a threshold value of hard threshold filtering to obtain primary noise-reduced OCT grain images;
3) filtering the primary noise-reduced OCT seed image by using a Prewitt edge detection operator to realize edge detection, obtaining the OCT seed image after the edge detection, and then performing median filtering on the OCT seed image after the edge detection by using a custom template [2,6] to remove isolated pixel points; finally, carrying out binarization processing to obtain a binarization grain image;
searching pixel points with a first gray value of 1 in the current row of pixel points from top to bottom and recording the pixel points as pixel points to be fitted for each row of pixel points in the binarized seed image; traversing all columns of pixel points in the binarized grain image to obtain all pixel points to be fitted in the binarized grain image;
and fitting all pixel points to be fitted by utilizing a Gaussian Mixture Model (GMM) fitting method to obtain a first boundary line of the background and the corn kernels, and obtaining all pixel points corresponding to the boundary line of the background and the corn kernel target.
4) Searching the highest point of a first boundary line of the background and the corn kernel, and performing flattening transformation on the primary noise-reduced OCT kernel image by taking the highest point of the first boundary line as a reference, wherein the flattening transformation specifically comprises the following steps: carrying out upward translation on each row in the primary noise-reduced OCT grain image by using the highest point of the first boundary line, wherein 0 is inserted into the supplemented pixel, and obtaining the flattened and transformed OCT grain image; as shown in fig. 3, (a) of fig. 3 shows before leveling, and (b) of fig. 3 shows after leveling.
5) Taking a boundary line in the OCT seed image after the flattening transformation as a second boundary line of the background and the corn seed, and cutting the OCT seed image after the flattening transformation by taking the second boundary line as a reference, wherein mould is positioned on the pericarp and the seed coat of the corn seed, and part of the mould can be positioned in a background area; meanwhile, a background area exceeding a preset distance of the second boundary in the upper half part is cut, and an OCT grain image after cutting is obtained; the OCT kernel image after the leveling transformation sequentially comprises an air background, a fruit peel, a seed coat, an aleurone layer and an endosperm from top to bottom.
In this embodiment, only the OCT kernel image after the leveling transformation is longitudinally cropped (or the midpoint of the upper boundary of the image is taken as a reference), the cropping range is 20 pixels above the boundary, and the range of the lower 10 pixels is taken as an input image of the subsequent step; fig. 4 shows the effect of clipping fig. 3.
6) Extracting the boundary of the corn kernel pericarp and the seed coat; the step 6) is specifically as follows:
6.1) defining the correlation weight between two communicated pixel points according to the gray value of the pixel, wherein each pixel point is communicated with each adjacent pixel point; all phases were calculated using the following formulaCorrelation Weight between two connected pixel pointsab:
Weightab=2.01-ga-gb
Wherein, gaAnd gbPixel gray values of two communicated pixel points a and b are respectively obtained;
6.2) calculating the gray value of each pixel point in the cut OCT seed image and carrying out normalization processing;
6.3) adding 4 rows of pixel points on the leftmost side and the rightmost side of the cut image respectively, wherein the associated weight of each two communicated pixel points in the leftmost row of pixels and the rightmost row of pixels is zero;
6.4) taking the middle pixel point of the leftmost column of pixel points as an initial point of boundary search, taking the middle pixel point of the rightmost column of pixel points as an end point of boundary search, and adopting a shortest path search algorithm in a Floyd multivariate path by combining the communication condition and the correlation weight of each pixel point in the image to obtain a primary upper boundary of the pericarp and the pericarp of the corn kernel;
6.5) smoothing the preliminary upper boundary of the corn kernel peel and the seed coat by using a 10-pixel smoothing algorithm 7) calculating the average gray level of the upper boundary of the corn kernel peel and the seed coat, wherein N times (N is 0.2-0.8) of the average gray level is used as a filtering threshold, and in the embodiment, N is 0.6; setting 0 for pixel points smaller than a filtering threshold value in the cut OCT seed image, and not processing the pixel points larger than or equal to the filtering threshold value in the cut OCT seed image to obtain the boundary of the pericarp and the seed coat of the filtered corn seed;
8) calculating the number of non-0 pixels in the current front row of pixels on the boundaries of the fruit skin and the seed skin of the filtered corn kernel by taking the row pixels as a unit, taking the number of the non-0 pixels in the current row of pixels as the array value of the current row, and traversing all rows of pixels to obtain a one-dimensional upper boundary array;
9) taking an array average value of the one-dimensional upper boundary array, taking M times (M is between 2 and 3) of the array average value as a discrimination threshold, wherein M is 2.5 in the embodiment; comparing each array value in the one-dimensional upper boundary array with a discrimination threshold, and if the array value is greater than the discrimination threshold, indicating that an early mildew point exists in the row of pixel points where the array value is located; if the array value is less than or equal to the discrimination threshold, indicating that no early mildew point exists in the column pixel point of the current array value; fig. 5 is a graph showing the effect of automatic marking of the mildew location for the presence of one of the early mildew samples (i.e., subsequent to fig. 4), with the triangle marked by the mildew location.
In the embodiment, 30 OCT image samples of corn kernels are collected, wherein 15 samples contain early mildew, and 15 samples are normal samples (a control group); the specific positions of 15 early mildew samples on the experimental surface can be automatically marked by the identification method, and the 15 comparison group samples are judged to be free of mildew by the identification method, so that the accuracy rate is 100%.
In the embodiment of the present invention, it can be further understood by those skilled in the art that all or part of the steps in the method for implementing the above embodiment may be implemented by instructing the relevant hardware through a program, where the program may be stored in a computer-readable storage medium, where the storage medium includes a ROM/RAM, a magnetic disk, an optical disk, and the like.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents and improvements made within the spirit and principle of the present invention are intended to be included within the scope of the present invention.
- 上一篇:石墨接头机器人自动装卡簧、装栓机
- 下一篇:一种高速铁路接触网目标检测与跟踪方法