Disclosure of Invention
The technical problem to be solved by the invention is to provide a corn seed internal crack detection method based on correlation filtering aiming at the problems in the prior art.
In order to achieve the purpose, the invention provides a corn seed internal crack detection method based on correlation filtering, which comprises the following steps:
s100, acquiring a seed transmission image by using a color camera and a high-brightness light source, and constructing a seed crack data set according to the seed transmission image;
s200, constructing a seed crack related filtering template and a related threshold value by using the seed crack data set;
s300, performing edge detection on a non-seed region of the seed to be detected by using the related filtering template, and extracting a candidate region with high correlation with the seed crack;
s400, crack screening, namely comparing a correlation filtering response peak value and a correlation threshold value of the candidate region, and judging whether the candidate region is a seed crack region according to a comparison result; and
s500, connecting the pixel points of the screened seed crack area to obtain a seed crack detection result.
In the method for detecting the internal crack of the corn seed based on the correlation filtering, in step S200, the seed crack data set is operated through fourier transform and gaussian transform to obtain the seed crack correlation filtering template.
The maize seed internal crack detection method based on the correlation filtering is characterized in that the construction of the seed crack correlation filtering template further comprises the following steps:
s201, randomly extracting seed cracks in the seed crack data set, and forming a set S ═ f by taking k × k as an arbitrary region of a template size and taking the seed crack pixel points as centers1,f2,...,fNN is a seed crack sample;
s202, according to a related filtering principle, inputting the seed transmission image and the related filtering template to calculate to obtain a following related graph g:
wherein f is the seed transmission image, h is the correlation filtering template,
performing convolution operation;
s203, Fourier transform is carried out on the above expression, and the Fourier transform of the function cross correlation is equal to the product of the function Fourier transform:
wherein, denotes the conjugate calculation, F (-) is the fourier transform;
s204, simplifying the formula as follows: g ═ F · H
*Obtaining:
wherein H*Is the seed crack correlation filter template, G is the expected response.
The maize seed internal crack detection method based on the correlation filtering is characterized in that the construction of the seed crack correlation filtering template further comprises the following steps:
s205, solving by adopting a minimized sum of squares error for N seed crack samples in the set S:
where G is a standard Gaussian function with a peak value of 1.
The maize seed internal crack detection method based on the correlation filtering is characterized in that the edge detection in step S300 further includes:
adopting scharr operator to carry out edge calculation to obtain an edge image ci:
Where x is the seed transmission image sample with internal cracks, xiRepresenting the ith sample data (i ═ 1, 2.., N), where N is the number of crack samples; kxIs the filter coefficient in the x direction, KyIs the filter coefficient in the y direction.
The corn seed internal crack detection method based on the correlation filtering is characterized in that Kx,KyRespectively as follows:
in the corn seed internal crack detection method based on correlation filtering, only the edge image of the seed in the circular light-transmitting area is calculated, and the radius of the circular light-transmitting area is R.
The maize seed internal crack detection method based on correlation filtering is characterized in that the crack screening in the step S400 further comprises:
with ciTaking an edge pixel point as a center, acquiring a rectangular image area P with the size of k multiplied by k, and performing Fourier transform on the rectangular image area P to obtain P, wherein the relevant filtering response is as follows:
Y=H*·P
wherein, ciFor the output image after edge detection, H*P is a candidate region for the filter template.
In the method for detecting internal cracks of corn seeds based on correlation filtering, a threshold T is set, and if the peak value of the correlation filtering response is greater than or equal to the threshold T, the candidate region is a crack region; and if the peak value of the correlation filtering response is smaller than a threshold value T, the candidate region is a non-crack region.
In order to better achieve the above object, the present invention further provides a corn seed internal crack detection method based on correlation filtering, wherein the method comprises the following steps:
constructing a seed crack data set: acquiring a crack region image with the size of k multiplied by k by taking a crack pixel point as a center according to the seed transmission image to form a seed crack data set;
and (3) calculating a filtering template: setting the target response as a standard Gaussian function with the peak value of 1, carrying out Fourier transform on the crack image, obtaining a corresponding related filtering template according to a filtering template calculation formula, and carrying out iterative solution through a least square sum error to obtain a final filtering template H*;
Carrying out edge detection on the seed transmission image to obtain a candidate region of the seed crack;
taking the edge detection result as a mask, and carrying out pixel correspondence with the original seed transmission image;
taking candidate edge pixel points in the edge detection result as a center, intercepting a k multiplied by k original seed transmission image as candidate region input, and performing Fourier transform on the candidate region to obtain a relevant filtering response of the candidate region;
judging the peak value of the relevant filtering response, and if the peak value is greater than or equal to a threshold value T, determining that the candidate region is a crack region; if the peak value is smaller than the threshold value T, the candidate area is a non-crack area;
circularly traversing all candidate regions of edge detection, and returning to obtain relevant filtering response of the candidate regions again if the traversal is not completed; and if traversing is finished, connecting the crack areas of the seeds in sequence to finish the detection of the cracks in the seeds.
The invention has the technical effects that:
the method can quickly and efficiently detect the internal cracks of the corn, meets the requirements of refinement, intellectualization and standardization of seeds, provides support for guaranteeing the safety of seed utilization, mechanized efficient sowing and crop yield increase, and provides technical support for nondestructive detection of agricultural seed utilization.
The invention is described in detail below with reference to the drawings and specific examples, but the invention is not limited thereto.
Detailed Description
The invention will be described in detail with reference to the following drawings, which are provided for illustration purposes and the like:
the invention provides a corn seed internal crack detection method based on relevant filtering based on an image processing technology, a machine learning technology and a signal filtering technology, and a seed transmission image is obtained by utilizing a color camera and a high-brightness light source. And according to the actual situation, removing the non-seed area by using the template. The method comprises the steps of converting time domain calculation of an image into frequency domain calculation by utilizing a correlation filtering principle, extracting a region with high correlation with a seed crack part by constructing a correlation filtering template and a correlation threshold value, and finally connecting screened pixel points to realize detection and identification of the crack part. The method specifically comprises the following steps:
s100, acquiring a seed transmission image (see figure 1) by using a color camera and a high-brightness light source, and constructing a seed crack data set according to the seed transmission image;
s200, constructing a seed crack related filtering template and a related threshold value by using the seed crack data set;
s300, performing edge detection on a non-seed region of the seed to be detected by using the related filtering template, and extracting a candidate region with high correlation with the crack of the seed;
s400, crack screening, namely comparing a correlation filtering response peak value and a correlation threshold value of the candidate region, and judging whether the candidate region is a seed crack region or not according to a comparison result; and
and S500, connecting the pixel points of the screened seed crack area as a seed crack detection result.
In this embodiment, in step S200, the seed crack data set is operated through fourier transform and gaussian transform to obtain the seed crack related filtering template. Further comprising:
step S201, in the seed crack data set, randomly extracting seed cracks and calculating the seed cracksThe seed crack pixel point is taken as the center, and an arbitrary region with the size of k multiplied by k as a template forms a set S ═ f1,f2,...,fNN is a seed crack sample;
step S202, according to the relevant filtering principle, inputting the seed transmission image f and the relevant filtering template h to calculate to obtain the following relevant graph g:
wherein f is the seed transmission image, h is the correlation filtering template,
performing convolution operation;
step S203, in order to increase the calculation speed, fourier transform is performed on the above equation, and it can be known from the convolution theorem that the fourier transform of the functional cross-correlation is equal to the product of the functional fourier transform:
wherein, denotes the conjugate calculation, F (-) is the fourier transform;
step S204, the above formula is simplified as follows:
G=F·H*(3) then, we can get:
wherein H*Is a seed crack correlation filter template, G is an expected response, where the peak is a standard Gaussian function of 1; and
step S205, solving by using a minimum sum of squares error for N seed crack samples in the set S:
where G is a standard Gaussian function with a peak value of 1.
Wherein, the edge detection in step S300 further includes:
according to the practical situation, the seed crack is a gap with edge characteristics, so that the suspected region of the seed crack is firstly deleted by using an edge detection method to obtain an edge image ciFor further investigation. Since the seed crack region is often weak, the edge calculation is performed using the scharr operator, and the filter coefficient is shown as KxIs the filter coefficient in the x direction, KyFor the filter coefficients in the y-direction, an edge image c is obtainedi:
Referring to fig. 2, fig. 2 is a schematic diagram of crack seed edge detection according to an embodiment of the invention. Where x is the seed transmission image sample with internal cracks, let x beiRepresenting the ith sample data (i ═ 1, 2.., N), where N is the number of crack samples; kxIs the filter coefficient in the x direction, KyThe filter coefficient in the y direction is, according to the actual situation, the seed is in the circular light-transmitting area, so only the edge image of the seed in the circular light-transmitting area is calculated, and the radius of the circular light-transmitting area is R.
Wherein Kx,KyRespectively as follows:
referring to fig. 3, fig. 3 is a schematic diagram of crack screening according to an embodiment of the invention. Wherein the crack screening in step S400 further comprises:
from the above formula (6) to obtain ciFor the output image after edge detection, H*Is a filtering template. With ciAs a mask, taking an edge pixel point as a center, obtaining a rectangular image region P with a size of k × k and performing fourier transform to obtain P, as shown in fig. 3, if an objective function is a gaussian function according to formula (4), a relevant filter response is as follows:
Y=H*·P (9);
wherein, ciFor the output image after edge detection, H*P is a candidate region for the filter template.
From the above equation, if the input p is a crack region, the output filter response should be a gaussian-like function; if the input is not a seed crack region, but is other regions with edge features, the output response is not a gaussian function. Setting a threshold T for accelerating judgment, and if the peak value of the relevant filtering response is greater than or equal to the threshold T, determining that the candidate region is a crack region; and if the peak value of the correlation filtering response is smaller than a threshold value T, the candidate region is a non-crack region. And finally, connecting the crack pixel points to obtain a seed crack detection result.
The corn seed internal crack detection method based on the correlation filtering comprises the following steps of:
step 1, constructing a crack part data set: acquiring a crack region image with the size of k multiplied by k (k is 7) by taking a crack pixel point as a center according to the seed transmission image, and constructing a seed crack data set;
step 2, calculating a filtering template: setting the target response as a standard Gaussian function with the peak value of 1, carrying out Fourier transform on the crack image, obtaining a corresponding related filtering template according to a filtering template calculation formula, and carrying out iterative solution through a least square sum error to obtain a final filtering template H*;
And 3, according to the actual situation, the seed is in the circular light-transmitting area, so that only the image in the circular area participates in calculation, the image outside the circular area does not participate in calculation, and the radius of the circle in the image is R (R is 112). Carrying out edge detection on the seed transmission image to obtain a candidate region of the seed crack;
step 4, taking the edge detection result as a mask, and carrying out pixel correspondence with the original seed transmission image;
step 5, taking the candidate edge pixel point in the edge detection result as the center, intercepting the k multiplied by k original seed transmission image as the input of the candidate area, carrying out Fourier transform on the candidate area, and then solving by using a formula (9) to obtain the relevant filtering response of the candidate area;
step 6, judging a peak value of the correlation filtering response, and if the peak value is greater than or equal to a threshold value T (T is 0.7), determining that the candidate region is a crack region; if the peak value is smaller than the threshold value T, the candidate area is a non-crack area;
7, circularly traversing all candidate regions of edge detection, and returning to the step 5 to obtain relevant filtering responses of the candidate regions again if traversing is not finished; if the traversal is finished, entering the step 8;
and 8, connecting the crack regions of the seeds in sequence to complete the detection of the internal cracks of the seeds.
The invention utilizes a color camera and a high-brightness point light source to obtain the transmission image of the corn seed. And (4) utilizing correlation filtering analysis to count crack parts in the crack seeds, and obtaining a crack correlation filtering template through operations such as Fourier transform, Gaussian transform and the like. And (3) converting time domain calculation into frequency domain calculation, and quickly positioning the crack part of the seed, thereby completing the internal crack detection of the corn seed and realizing the positioning and identification of the internal crack of the corn seed.
The present invention may be embodied in other specific forms without departing from the spirit or essential attributes thereof, and it should be understood that various changes and modifications can be effected therein by one skilled in the art without departing from the spirit and scope of the invention as defined in the appended claims.