Disclosure of Invention
In order to solve the problems, the technical scheme of the invention is as follows: a peanut aflatoxin detection device based on prism type RGB color extraction comprises a control box and a computer, wherein the control box and the computer are connected through a control cable, an industrial camera and an ultraviolet lamp light source are arranged in the control box, the industrial camera is connected with the computer, an object stage is further arranged in the control box, the object stage is arranged right below the industrial camera, and the ultraviolet lamp light source is respectively arranged on two sides of the industrial camera;
the control box is a lightproof black box body during photographing, an opening is formed in the side face of the control box, and peanuts are placed on the objective table through the opening;
the industrial camera is a prism type industrial R-G-B area array scanning camera;
the control cable comprises a GigE gigabit internet access digital connecting line for controlling the industrial camera to be connected with the computer and a control cable for controlling the ultraviolet lamp light source to be connected with the computer;
and the computer receives the image data of the peanuts collected by the industrial camera, processes and analyzes the image data and determines whether the peanuts are infected with the aflatoxin.
Preferably, the ultraviolet lamp light source comprises a lamp panel, and an ultraviolet lamp tube is embedded in the lamp panel through a groove formed in the lamp panel.
Preferably, the object stage is a glass sheet with both sides frosted.
Based on the purpose, the invention also provides a peanut aflatoxin detection method based on prism type RGB color extraction, and the peanut aflatoxin detection device based on the prism type RGB color extraction comprises the following steps:
s10, after a peanut aflatoxin detection device based on prism type RGB color extraction is built, an ultraviolet lamp light source is turned on, and an industrial camera collects color RGB images of peanuts;
s20, the industrial camera sends the collected color RGB images of the peanuts to a computer for filtering, and then background segmentation is carried out on the processed images to obtain images with background removed;
and S30, extracting R, G, B colors from the image with the background removed in the step S20, judging the similar colors of the aflatoxin on each peanut, and if the similar colors of the aflatoxin on each peanut exceed a set threshold value, judging that the peanut is infected by the aflatoxin.
Preferably, the filtering processing in S20 adopts wiener filtering, and the local mean of each pixel is:
the variance of each pixel is:
the wiener filter estimation equation is:
wherein S represents an M multiplied by N local neighborhood of each pixel point in the image; delta2Representing the noise variance, can be replaced by the mean of all local estimated variances.
Preferably, the background segmentation of the filtered peanut color RGB image in S20 includes the following steps:
s21, performing edge extraction, namely processing the peanut color RGB image after filtering by adopting a Canny edge detection operator and extracting edges to obtain a peanut edge extraction image;
s22, performing morphological filtering, namely removing image noise of the peanut edge extraction image by adopting the morphological filtering to obtain a peanut image subjected to morphological filtering;
s23, image filling and marking, namely marking the occupied area of the peanuts in the image by adopting a scanning line seed filling method for the peanut area in the peanut image after the morphological filtering processing to obtain a marked peanut image;
and S24, synthesizing images, namely taking the marked peanut images as masks, performing AND operation on the masks and R, G, B of the source images to obtain bit-sum operated R, G, B images, and combining the bit-sum operated R, G, B images to obtain background-segmented images.
Preferably, the processing and extracting the edge by using the Canny edge detection operator comprises the following steps:
s211, smoothing the image by using a Gaussian filter;
s212, calculating a gradient amplitude image and a gradient angle image;
s213, applying non-maximum suppression to the gradient amplitude image;
s214, detecting and connecting edges by using double threshold processing and connectivity.
Preferably, the morphological filtering in S22 includes expansion, erosion, opening operation and closing operation.
Preferably, when R, G, B color extraction is performed on the image in S30, the following determination rules are adopted for R, G, B three colors: when the difference value between one color component and the other two color components in R, G, B is greater than a set value, a certain pixel point is judged to be a certain color, and the color of the judgment condition is controlled by setting a judgment threshold value.
Preferably, the threshold in S30 is a value of the color area of the image after the judgment R, G, B color extraction, and if the value is beyond a set range of the value, the peanut is judged to be infected with aflatoxin.
Compared with the prior art, the invention has the following beneficial effects:
the invention adopts an ultraviolet lamp light source, if the peanuts are infected with the aflatoxin, a specific fluorescent reaction can occur under the irradiation of the light source; the invention adopts a prism type industrial R-G-B area array scanning camera which is provided with three CMOS sensors, each sensor is responsible for one color, and compared with a single CMOS sensor, the camera is more sensitive to the color and can provide better color fidelity and spatial resolution; when peanut image acquisition is carried out, an ultraviolet lamp light source is turned on, the computer controls the industrial camera to synchronously trigger, the industrial camera sends the image of the peanut under the irradiation of the ultraviolet lamp light source to the computer, the aflatoxin can generate a fluorescence reaction under the irradiation of the ultraviolet lamp, the peanut infected by the aflatoxin can also generate the fluorescence reaction, and the fluorescence reaction can not occur under the normal occurrence of the peanut not infected by the aflatoxin. The computer extracts the R-G-B color image of the peanut and compares the R-G-B color image with a preset judgment threshold value to detect whether the peanut is infected with the aflatoxin, so that whether the peanut is infected with the aflatoxin is accurately detected.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
On the contrary, the invention is intended to cover alternatives, modifications, equivalents and alternatives which may be included within the spirit and scope of the invention as defined by the appended claims. Furthermore, in the following detailed description of the present invention, certain specific details are set forth in order to provide a better understanding of the present invention. It will be apparent to one skilled in the art that the present invention may be practiced without these specific details.
The applicant carries out deep research on the structure of the traditional broadband high-efficiency power amplifier in the prior art aiming at the defects in the prior art, and finds that the traditional broadband high-efficiency power amplifier in the prior art is relatively single in mode, relatively complex in structure, relatively high in implementation difficulty, relatively large in overall circuit volume and relatively high in cost.
In order to overcome the defects of the prior art, referring to fig. 1-3, the structural block diagram of the peanut aflatoxin detection device based on prism type RGB color extraction is shown, the device comprises a computer 1 and a control box 2, an industrial camera 5 is arranged in the control box 1, the industrial camera 5 is connected with the computer 1, an object stage 8 is arranged right below the industrial camera in the control box 2, ultraviolet lamp light sources 6 and 7 are respectively arranged on two sides of the industrial camera 5 in the control box 2, and a control cable 4 for connecting the computer and the control box is arranged.
The control box 2 is a lightproof black box body used for isolating the interference of an external light source when in shooting; and the control box 2 is provided with an opening 3 for putting peanuts on the object stage 8.
The industrial camera 5 is a prism type industrial R-G-B area array scanning camera and can acquire peanut images with better color fidelity and spatial resolution.
The ultraviolet lamp light sources 6 and 7 comprise lamp panels 9, ultraviolet lamp tubes 10 are embedded in the lamp panels through grooves formed in the lamp panels, and the lamp panels are matched with the industrial camera 5 for use.
The object stage 8 is a glass sheet with both sides frosted.
The control cable 4 comprises a GigE gigabit internet access digital connecting line for controlling the connection of the industrial camera 5 and the computer 1 and a control cable for controlling the connection of the ultraviolet lamp light sources 6 and 7 and the computer 1, and is matched with the industrial camera 5 and the computer 1 for use.
The computer 1 is used for receiving the image data of the peanuts collected by the industrial camera 5, and the computer 1 processes and analyzes the image data to determine whether the peanuts are infected with the aflatoxin.
Referring to fig. 4, the invention also provides a peanut aflatoxin detection method based on prism type RGB color extraction, and the peanut aflatoxin detection device based on prism type RGB color extraction comprises the following steps:
s10, after a peanut aflatoxin detection device based on prism type RGB color extraction is built, an ultraviolet lamp light source is turned on, and an industrial camera collects color RGB images of peanuts;
s20, the industrial camera sends the collected color RGB images of the peanuts to a computer for filtering, and then background segmentation is carried out on the processed images to obtain images with background removed;
and S30, extracting R, G, B colors from the image with the background removed in the step S20, judging the similar colors of the aflatoxin on each peanut, and if the similar colors of the aflatoxin on each peanut exceed a set threshold value, judging that the peanut is infected by the aflatoxin.
Aflatoxins G1 and G2 emit green fluorescence under the irradiation of an ultraviolet lamp light source, aflatoxins B1 and B2 emit blue fluorescence under the irradiation of the ultraviolet lamp light source, and if aflatoxins are infected in S10, the color RGB images of peanuts collected by an industrial camera under the irradiation of the ultraviolet lamp light source also show fluorescence reaction. In the S20, filtering processing adopts wiener filtering, and the local mean value of each pixel point is as follows:
the variance of each pixel is:
the wiener filter estimation equation is:
wherein S represents an M multiplied by N local neighborhood of each pixel point in the image; delta2Representing the noise variance, can be replaced by the mean of all local estimated variances.
The background segmentation of the peanut color RGB image after the filtering processing in the S20 comprises the following steps:
s21, performing edge extraction, namely processing the peanut color RGB image after filtering by adopting a Canny edge detection operator and extracting edges to obtain a peanut edge extraction image;
s22, performing morphological filtering, namely removing image noise of the peanut edge extraction image by adopting the morphological filtering to obtain a peanut image subjected to morphological filtering;
s23, image filling and marking, namely marking the occupied area of the peanuts in the image by adopting a scanning line seed filling method for the peanut area in the peanut image after the morphological filtering processing to obtain a marked peanut image;
and S24, synthesizing images, namely taking the marked peanut images as masks, performing AND operation on the masks and R, G, B of the source images to obtain bit-sum operated R, G, B images, and combining the bit-sum operated R, G, B images to obtain background-segmented images.
The method for processing and extracting the edge by adopting the Canny edge detection operator comprises the following steps:
s211, smoothing the image by using a Gaussian filter;
s212, calculating a gradient amplitude image and a gradient angle image;
s213, applying non-maximum suppression to the gradient amplitude image;
s214, detecting and connecting edges by using double threshold processing and connectivity.
The morphological filtering in S22 includes dilation, erosion, open and close operations.
When R, G, B color extraction is performed on the image in S30, the following discrimination rules are adopted for R, G, B three colors: when the difference value between one color component and the other two color components in R, G, B is greater than a set value, a certain pixel point is judged to be a certain color, and the color of the judgment condition is controlled by setting a judgment threshold value.
And the threshold value in the S30 is the value of the image color area after the judgment R, G, B color extraction, and if the value is beyond the set range of the value, the peanut is judged to be infected with the aflatoxin.
In a specific embodiment, when R, G, B color extraction is performed on the image in S30, the following determination rules are adopted for R, G, B three colors: when the difference value between a certain color component and the other two color components in R, G, B is greater than a preset value, that is, a certain pixel point is judged to be a certain color, and the color of the judgment condition is controlled by setting a judgment threshold, the specific operation steps are as follows: setting R, G, B three color extraction thresholds, extract _ R0, extract _ G0, and extract _ B0, wherein the color extraction threshold is set to zero in advance, and the larger the color extraction threshold is set, the smaller the extraction range, then extracting R, G, B three colors respectively, the red extraction condition is that the difference between the R component and the G, B component is greater than the setting, the green extraction condition is that the difference between the G component and the R, B component is greater than the setting, and the green extraction condition is that the difference between the G component and the R, B component is greater than the setting.
However, that no matter how detailed the foregoing appears, or how many embodiments of the invention may be practiced, the present invention is described in detail as illustrative embodiments thereof. All equivalent changes and modifications made according to the spirit of the present invention should be covered within the protection scope of the present invention.
The foregoing detailed description of the embodiments of the invention is not intended to be exhaustive or to limit the invention to the precise form disclosed. While specific embodiments of, and examples for, the invention are described above for illustrative purposes, various equivalent modifications are possible within the scope of the invention, as those skilled in the relevant art will recognize.
While the above description describes certain embodiments of the invention and describes the best mode contemplated, no matter how detailed the above appears in text, the invention can be practiced in many ways. The details of the above-described circuit configuration and manner of controlling the same may vary considerably in its implementation details, yet still be encompassed by the invention disclosed herein.
As noted above, it should be noted that the use of particular terminology when describing certain features or aspects of the invention should not be taken to imply that the terminology is being re-defined herein to be restricted to certain specific characteristics, features, or aspects of the invention with which that terminology is associated. In general, the terms used in the following claims should not be construed to limit the invention to the specific embodiments disclosed in the specification, unless the above detailed description section explicitly defines such terms. Accordingly, the actual scope of the invention encompasses not only the disclosed embodiments, but also all equivalent ways of practicing or implementing the invention under the claims.
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.