CN112819746B - Nut kernel worm erosion defect detection method and device - Google Patents

Nut kernel worm erosion defect detection method and device Download PDF

Info

Publication number
CN112819746B
CN112819746B CN201911054851.3A CN201911054851A CN112819746B CN 112819746 B CN112819746 B CN 112819746B CN 201911054851 A CN201911054851 A CN 201911054851A CN 112819746 B CN112819746 B CN 112819746B
Authority
CN
China
Prior art keywords
detected
image
insect
detection
area
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201911054851.3A
Other languages
Chinese (zh)
Other versions
CN112819746A (en
Inventor
乐翠
孙彪
李建峰
孙春泉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hefei Meyer Optoelectronic Technology Inc
Original Assignee
Hefei Meyer Optoelectronic Technology Inc
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hefei Meyer Optoelectronic Technology Inc filed Critical Hefei Meyer Optoelectronic Technology Inc
Priority to CN201911054851.3A priority Critical patent/CN112819746B/en
Publication of CN112819746A publication Critical patent/CN112819746A/en
Application granted granted Critical
Publication of CN112819746B publication Critical patent/CN112819746B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/0002Inspection of images, e.g. flaw detection
    • GPHYSICS
    • G01MEASURING; TESTING
    • G01NINVESTIGATING OR ANALYSING MATERIALS BY DETERMINING THEIR CHEMICAL OR PHYSICAL PROPERTIES
    • G01N23/00Investigating or analysing materials by the use of wave or particle radiation, e.g. X-rays or neutrons, not covered by groups G01N3/00 – G01N17/00, G01N21/00 or G01N22/00
    • G01N23/02Investigating or analysing materials by the use of wave or particle radiation, e.g. X-rays or neutrons, not covered by groups G01N3/00 – G01N17/00, G01N21/00 or G01N22/00 by transmitting the radiation through the material
    • G01N23/04Investigating or analysing materials by the use of wave or particle radiation, e.g. X-rays or neutrons, not covered by groups G01N3/00 – G01N17/00, G01N21/00 or G01N22/00 by transmitting the radiation through the material and forming images of the material
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/12Edge-based segmentation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/136Segmentation; Edge detection involving thresholding
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/10Segmentation; Edge detection
    • G06T7/187Segmentation; Edge detection involving region growing; involving region merging; involving connected component labelling
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/60Analysis of geometric attributes
    • G06T7/62Analysis of geometric attributes of area, perimeter, diameter or volume
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/20Image preprocessing
    • G06V10/26Segmentation of patterns in the image field; Cutting or merging of image elements to establish the pattern region, e.g. clustering-based techniques; Detection of occlusion
    • G06V10/267Segmentation of patterns in the image field; Cutting or merging of image elements to establish the pattern region, e.g. clustering-based techniques; Detection of occlusion by performing operations on regions, e.g. growing, shrinking or watersheds
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06VIMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
    • G06V10/00Arrangements for image or video recognition or understanding
    • G06V10/20Image preprocessing
    • G06V10/28Quantising the image, e.g. histogram thresholding for discrimination between background and foreground patterns
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10116X-ray image

Abstract

The invention discloses a method and a device for detecting insect erosion defects of nut kernels, wherein the method comprises the following steps: acquiring an image to be detected, wherein the image to be detected is an external rectangular X-ray image of a material to be detected; according to the image to be detected, carrying out external insect corrosion detection on the material to be detected, wherein the external insect corrosion detection comprises the following steps: sequentially performing binarization processing and convex hull processing on the image to be detected to respectively obtain a binarized image and a convex hull image, and subtracting the convex hull image from the binarized image to obtain a concave area; judging whether the material to be detected has external insect-erosion defects or not according to the area of the concave area. The method comprises the steps of taking an external rectangular X-ray image of a material to be detected as the image to be detected, carrying out binarization processing and convex hull processing on the image to be detected to obtain a concave area in the image to be detected, and judging whether the material to be detected has an external insect-erosion defect according to the area of the concave area. The method has the advantages of high detection efficiency, high accuracy, automatic detection and the like.

Description

Nut kernel worm erosion defect detection method and device
Technical Field
The invention relates to the technical field of X-ray detection, in particular to a method and a device for detecting insect erosion defects of nut kernels.
Background
In recent years, nuts have become popular and sales have increased year by year. However, nut kernels (such as almond, etc.) are extremely prone to insect growth, and if the nut can not be effectively sorted before sale, an extremely poor experience will be brought to the consumer, thereby affecting the reputation and market of the seller.
X-ray flaw detection is a detection method for judging the internal defect condition of a material by utilizing the fact that X-rays can penetrate the material and acquiring X-ray images according to the difference of the absorption and scattering actions of the material on the rays. Currently, X-ray flaw detection is often applied to the fields of metal material defect detection, rubber material defect detection such as tires and the like, wood defect detection and the like. However, there is no accurate and reliable detection method for the erosion defect of the nut kernel.
In the related art, detection of external insect-erosion defects of nut kernels is mostly realized through manual detection. The manual detection cannot ensure long-time efficient and stable sorting, and sorting personnel are easy to fatigue, so that wrong sorting or missed sorting can be caused, and the sorting efficiency of the nut kernels is lower. Thus, the existing nut kernel erosion defect detection method still needs to be improved.
Disclosure of Invention
The present invention aims to solve at least one of the technical problems in the related art to some extent. Therefore, an objective of the present invention is to provide a method and a device for detecting insect erosion defect of nut kernels. The invention can detect the insect erosion defect of the nut kernel with high efficiency, has high detection accuracy and can realize automatic detection.
In one aspect of the present invention, an embodiment of the present invention provides a method for detecting a nut kernel erosion defect, comprising:
acquiring an image to be detected, wherein the image to be detected is an external rectangular X-ray image of a material to be detected;
According to the image to be detected, carrying out external insect-erosion detection on the material to be detected, wherein the external insect-erosion detection comprises: sequentially performing binarization processing and convex hull processing on the image to be detected to respectively obtain a first binarization image and a first convex hull image, and subtracting the first convex hull image from the first binarization image to obtain a concave area; judging whether the material to be detected has external insect-corrosion defects or not according to the area of the concave area.
The method comprises the steps of taking an external rectangular X-ray image of a material to be detected as the image to be detected, carrying out binarization processing and convex hull processing on the image to be detected to obtain a concave area in the image to be detected, and judging whether the material to be detected has an external insect-erosion defect according to the area of the concave area. The method has the advantages of high detection efficiency, high accuracy, automatic detection and the like.
In addition, the method for detecting the erosion defect of the nut kernel according to the embodiment of the invention can also have the following additional technical characteristics:
in some embodiments of the present invention, before the step of performing external insect-attack detection on the material to be detected according to the image to be detected, the method further includes:
And carrying out center insect corrosion detection on the material to be detected according to the image to be detected, wherein the center insect corrosion detection comprises the following steps: sharpening, corroding and binarizing the image to be detected to obtain a second binarized image, and judging whether the material to be detected has a center insect-attack defect or not according to the area of the inner contour in the second binarized image;
and performing external insect corrosion detection on the material to be detected according to the image to be detected, wherein the method comprises the following steps:
And under the condition that the central insect-erosion defect does not exist, carrying out external insect-erosion detection on the material to be detected according to the image to be detected.
In some embodiments of the present invention, the step of determining whether the material to be detected has an external insect-erosion defect according to the area of the concave area includes:
if the area is smaller than the first preset threshold value and the number of the concave areas larger than the second preset threshold value is a preset number, and the distance from the concave areas to the image boundary is larger than the preset distance threshold value, determining that the material to be detected has an external insect-erosion defect;
Or alternatively, the first and second heat exchangers may be,
If the number of the concave areas with the area smaller than the first preset threshold value and larger than the second preset threshold value is a preset number, determining that the material to be detected has external insect-erosion defects.
In some embodiments of the present invention, before the step of performing center worm corrosion detection on the material to be detected according to the image to be detected, the method further includes:
judging whether adhesion exists in the material to be detected in the image to be detected;
the step of carrying out center worm corrosion detection on the material to be detected according to the image to be detected comprises the following steps:
And under the condition that adhesion does not exist, carrying out center insect corrosion detection on the material to be detected according to the image to be detected.
In one aspect of the present invention, an embodiment of the present invention provides a method for detecting a nut kernel erosion defect, comprising:
Acquiring a pre-detection image of a material to be detected, wherein the pre-detection image is an external rectangular X-ray image of the material to be detected;
judging whether adhesion exists in the materials to be detected in the pre-to-be-detected image;
If adhesion exists, dividing the material to be detected in the pre-to-be-detected image, and intercepting the external rectangular X-ray image of the material to be detected again to obtain the image to be detected;
judging whether the material to be detected is divided according to the image to be detected;
If the division is carried out, carrying out external insect-erosion detection on the material to be detected according to the image to be detected, wherein the external insect-erosion detection comprises the following steps: sequentially performing binarization processing and convex hull processing on the image to be detected to respectively obtain a first binarization image and a first convex hull image, and subtracting the first convex hull image from the first binarization image to obtain a concave area; judging whether the material to be detected has external insect-corrosion defects or not according to the area of the concave area.
According to the method, an external rectangular X-ray image of a material to be detected is used as the image to be detected, whether the situation that nuts and kernels are mutually adhered exists in the material to be detected is judged, when the material to be detected is adhered, the image is segmented, the segmented image is used as the image to be detected, a concave area in the image to be detected is obtained through binarization processing and convex hull processing of the image to be detected, and whether the material to be detected has external insect corrosion defects is judged according to the area of the concave area. The method has the advantages of high detection efficiency, high accuracy and the like.
In addition, the method for detecting the erosion defect of the nut kernel according to the embodiment of the invention can also have the following additional technical characteristics:
In some embodiments of the invention, the method further comprises:
If the material to be detected is not divided, center worm corrosion detection is carried out on the material to be detected according to the image to be detected, and the center worm corrosion detection comprises: and carrying out sharpening treatment, corrosion treatment and binarization treatment on the image to be detected to obtain a second binarization image, and judging whether the material to be detected has a center insect-corrosion defect or not according to the area of the inner contour in the second binarization image.
In some embodiments of the present invention, the step of determining whether the material to be detected has an external insect-attack defect according to the area of the concave area includes:
if the area is smaller than the first preset threshold value and the number of the concave areas larger than the second preset threshold value is a preset number, and the distance from the concave areas to the image boundary is larger than the preset distance threshold value, determining that the material to be detected has an external insect-erosion defect;
Or alternatively, the first and second heat exchangers may be,
If the number of the concave areas with the area smaller than the first preset threshold value and larger than the second preset threshold value is a preset number, determining that the material to be detected has external insect-erosion defects.
In some embodiments of the present invention, before the step of performing external insect-attack detection on the material to be detected according to the image to be detected, the method further includes:
And carrying out center insect corrosion detection on the material to be detected according to the image to be detected, wherein the center insect corrosion detection comprises the following steps: sharpening, corroding and binarizing the image to be detected to obtain a second binarized image, and judging whether the material to be detected has a center insect-attack defect or not according to the area of the inner contour in the second binarized image;
and performing external insect corrosion detection on the material to be detected according to the image to be detected, wherein the method comprises the following steps:
And under the condition that the central insect-erosion defect does not exist, carrying out external insect-erosion detection on the material to be detected according to the image to be detected.
In some embodiments of the present invention, before the center worm corrosion detection is performed on the material to be detected according to the image to be detected, the method further includes:
Sequentially performing binarization processing and convex hull processing on the image to be detected to respectively obtain a third binarization image and a second convex hull image, and subtracting the second convex hull image from the third binarization image to obtain a first concave region;
and if the number of the first concave areas with the area larger than the second preset threshold value is larger than the preset number, carrying out line drawing on the image to be detected.
In some embodiments of the invention, the method further comprises:
And under the condition that the first concave areas with the areas larger than the second preset threshold value are in a preset number, if the distance from the first concave areas to the image boundary is larger than the preset distance threshold value and the areas are smaller than the first preset threshold value, determining that the material to be detected has external insect-erosion defects, and if not, carrying out center insect-erosion detection on the material to be detected according to the image to be detected.
In some embodiments of the invention, the method further comprises: if no adhesion exists, taking the pre-detected image as an image to be detected, and carrying out external insect-erosion detection on the material to be detected according to the image to be detected, or carrying out center insect-erosion detection on the material to be detected according to the image to be detected, wherein the center insect-erosion detection comprises: and carrying out sharpening treatment, corrosion treatment and binarization treatment on the image to be detected to obtain a second binarization image, and judging whether the material to be detected has a center insect-corrosion defect or not according to the area of the inner contour in the second binarization image.
In some embodiments of the invention, the method further comprises: if no adhesion exists, taking the pre-detected image as an image to be detected, carrying out external insect-erosion detection on the material to be detected according to the image to be detected, and carrying out center insect-erosion detection on the material to be detected according to the image to be detected, wherein one of the two detection modes is executed firstly, and when no corresponding defect is detected, the other detection mode is executed; wherein, the center worm corrosion detection includes: and carrying out sharpening treatment, corrosion treatment and binarization treatment on the image to be detected to obtain a second binarization image, and judging whether the material to be detected has a center insect-corrosion defect or not according to the area of the inner contour in the second binarization image.
In some embodiments of the invention, the partitioning comprises: and sequentially performing binarization treatment, corrosion treatment and expansion treatment on the pre-detection image so as to divide the material to be detected in the pre-detection image.
In some embodiments of the present invention, the line drawing process includes: and drawing a line on the minimum distance between the first concave area with the largest area and the first concave area with the next largest area.
In some embodiments of the invention, the method further comprises:
acquiring a second concave area after line drawing;
Judging whether the line drawing is successful or not according to the first concave area and the second concave area, if not, determining the distances among the vertexes of a plurality of second concave areas with the areas larger than a second preset threshold value, and drawing the line between the two vertexes corresponding to the minimum distance.
In one aspect of the present invention, an embodiment of the present invention provides a nut kernel erosion defect detection device, comprising:
the image acquisition module is used for acquiring an image to be detected, wherein the image to be detected is an external rectangular X-ray image of a material to be detected;
The external insect corrosion detection module is used for carrying out external insect corrosion detection on the material to be detected according to the image to be detected, and the external insect corrosion detection comprises: sequentially performing binarization processing and convex hull processing on the image to be detected to respectively obtain a first binarization image and a first convex hull image, and subtracting the first convex hull image from the first binarization image to obtain a concave area; judging whether the material to be detected has external insect-corrosion defects or not according to the area of the concave area.
In one aspect of the present invention, an embodiment of the present invention provides a nut kernel erosion defect detection device, comprising:
the image acquisition module is used for acquiring a pre-detection image of the material to be detected, wherein the pre-detection image is an external rectangular X-ray image of the material to be detected;
The first judging module is used for judging whether adhesion exists in the materials to be detected in the pre-to-be-detected image;
The segmentation module is used for segmenting the material to be detected in the pre-detection image when the judgment result of the first judgment module is that adhesion exists, and intercepting the external rectangular X-ray image of the material to be detected again to obtain the image to be detected;
The second judging module is used for judging whether the material to be detected is split according to the image to be detected;
And the external insect-erosion detection module is used for carrying out external insect-erosion detection on the material to be detected according to the image to be detected when the judgment result of the second judgment module is division, and the external insect-erosion detection comprises: sequentially performing binarization processing and convex hull processing on the image to be detected to respectively obtain a first binarization image and a first convex hull image, and subtracting the first convex hull image from the first binarization image to obtain a concave area; judging whether the material to be detected has external insect-corrosion defects or not according to the area of the concave area.
Additional aspects and advantages of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention.
Drawings
The foregoing and/or additional aspects and advantages of the invention will become apparent and may be better understood from the following description of embodiments taken in conjunction with the accompanying drawings in which:
FIG. 1 is a flow chart of a method for detecting erosion defects of nut kernels according to an embodiment of the present invention;
FIG. 2 is a diagram of images involved in convex hull processing in accordance with one embodiment of the present invention;
FIG. 3 is a diagram of various images involved in convex hull processing in accordance with one embodiment of the present invention;
FIG. 4 is a flow chart of a method for detecting erosion defects of nut kernels according to an embodiment of the present invention;
FIG. 5 is a diagram of various images involved in a center etch detection process, according to one embodiment of the invention;
FIG. 6 is a flow chart of a method for detecting erosion defects of nut kernels according to one embodiment of the present invention;
FIG. 7 is a flow chart of a method for detecting erosion defects in nut kernels according to one embodiment of the present invention;
FIG. 8 is a flow chart of a method for detecting erosion defects in nut kernels according to one embodiment of the present invention;
FIG. 9 is a flow chart of a method for detecting erosion defects in nut kernels according to one embodiment of the present invention;
FIG. 10 is a diagram of various images involved in a segmentation process according to one embodiment of the present invention;
FIG. 11 is a diagram of various images involved in a line drawing process according to one embodiment of the present invention;
FIG. 12 is a schematic diagram of a device for detecting erosion defects of nut kernels according to an embodiment of the present invention;
Fig. 13 is a schematic structural view of a nut kernel erosion defect detecting device according to an embodiment of the present invention.
Detailed Description
Embodiments of the present invention are described in detail below, examples of which are illustrated in the accompanying drawings, wherein like or similar reference numerals refer to like or similar elements or elements having like or similar functions throughout. The embodiments described below by referring to the drawings are illustrative and intended to explain the present invention and should not be construed as limiting the invention.
Furthermore, the terms "first," "second," "third," and the like are used for descriptive purposes only and are not to be construed as indicating or implying a relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defining "a first", "a second", "a third", etc. may include at least one such feature, either explicitly or implicitly. In the description of the present invention, the meaning of "plurality" means at least two, for example, two, three, etc., unless specifically defined otherwise.
The specific type of the image processing software used in the detection method according to the present invention is not particularly limited, and MATLAB, openCV or the like may be used, for example. In addition, in the present invention, the term "binarization processing" refers to setting a pixel gray value larger than a preset threshold value in an image to be processed as a gray maximum value (i.e., black) and setting a pixel gray value smaller than or equal to the preset threshold value in the image to be processed as a gray minimum value (i.e., white) using image processing software.
In the embodiment of the present invention, the nut kernels may include almond kernels, apricot kernels, peanut kernels, melon kernels, hawaii kernels, pistachio kernels, etc., which are not particularly limited herein. The present invention will be described in detail with reference to the example of the almond.
In one aspect of the present invention, a method for detecting erosion defect of nuts is provided for detecting whether erosion defect exists in the almond kernels. Referring to fig. 1, according to an embodiment of the present invention, the method includes:
s11: and acquiring an image to be detected of the material to be detected, wherein the image to be detected is an external rectangular X-ray image of the material to be detected.
In the step, an X-ray image of a material to be detected is acquired through an imaging device of X-ray detection equipment, the material to be detected is intercepted by utilizing an external rectangle in the X-ray image, and the image to be detected is obtained, wherein the material to be detected is the almond as shown in fig. 2a and 3 a. According to some embodiments of the present invention, a method for intercepting a material to be detected by using an external rectangle comprises: firstly, performing binarization processing on an obtained X-ray image, then extracting the outline of a material to be detected, obtaining a rectangle along the edge of the outline, and performing amplification processing (for example, widening each side by 2-8 pixels) on each side of the rectangle to obtain the external rectangle, and intercepting the material to be detected from the X-ray image by using the external rectangle. By adopting the method, the image to be detected of the material to be detected is obtained by utilizing the external rectangle, the interference of other materials can be effectively eliminated, and the erroneous judgment caused by the adhesion of the materials is reduced.
S12: according to the image to be detected, carrying out external insect corrosion detection on the material to be detected, wherein the external insect corrosion detection comprises the following steps: sequentially performing binarization processing and convex hull processing on the image to be detected to respectively obtain a first binarization image and a first convex hull image, and subtracting the first convex hull image from the first binarization image to obtain a concave area; judging whether the material to be detected has external insect-erosion defects or not according to the area of the concave area.
According to an embodiment of the present invention, referring to fig. 2 and 3, fig. 2a and 3a are images to be detected of the bardawood kernel to be detected acquired according to S11, respectively. The binarization process and the convex hull process are sequentially performed with respect to fig. 2a to obtain fig. 2b and fig. 2c, respectively, and fig. 2d, which is a concave region outside the almond in fig. 2, is obtained by subtracting fig. 2b from fig. 2 c. The binarization process and the convex hull process are sequentially performed with respect to fig. 3a to obtain fig. 3b and 3c, respectively, and fig. 3d, which is a concave region outside the almond in fig. 3, is obtained by subtracting fig. 3b from fig. 3 c. Based on the obtained recessed areas, it can be determined whether the almond kernels in fig. 2 and 3 have external insect-attack defects, respectively.
According to an implementation manner of the embodiment of the present invention, the step of determining whether the material to be detected has an external insect-attack defect according to the area of the concave area may include: if the area is smaller than the first preset threshold value and the number of the concave areas larger than the second preset threshold value is preset, and the distance from the concave areas to the image boundary is larger than the preset distance threshold value, determining that the material to be detected has external insect-erosion defects. The inventor finds in the study that if the obtained number of the concave areas is too large, such as more than 2, the concave areas may be caused by adhesion of materials to be detected; the obtained area of the concave area is overlarge, namely larger than or equal to a first preset threshold value, and the area is possibly caused by adhesion and undivided material to be detected; the obtained distance from the concave region to the image boundary is smaller than or equal to the preset distance threshold value, and the erroneous judgment of the boundary region is possible. Therefore, judging whether the material to be detected has the external insect-attack defect or not according to the area and the number of the concave areas and the distance from the concave areas to the image boundary can eliminate the situation that the erroneous judgment is possible, and the accuracy of detecting the external insect-attack defect is improved.
According to another implementation manner of the embodiment of the present invention, the step of determining whether the material to be detected has an external insect-attack defect according to the area of the concave area may include: if the number of the concave areas with the area smaller than the first preset threshold value and larger than the second preset threshold value is a preset number, determining that the material to be detected has external insect-erosion defects. Judging whether the material to be detected has external insect-attack defects according to the area and the number of the concave areas can partially eliminate the situation that the error judgment possibly exists, and improves the accuracy of detecting the external insect-attack defects.
It should be noted that, by setting the first preset threshold, the concave area with a smaller area may be eliminated, and such similar concave area may not form an insect-attack defect, for example, the surface of the kernel is damaged due to scratch.
According to the method, an external rectangular X-ray image of a material to be detected is used as the image to be detected, whether the situation that nuts and kernels are mutually adhered exists in the material to be detected is judged, when the material to be detected is adhered, the image is segmented, the segmented image is used as the image to be detected, a concave area in the image to be detected is obtained through binarization processing and convex hull processing of the image to be detected, and whether the material to be detected has external insect corrosion defects is judged according to the area of the concave area. The method has the advantages of high detection efficiency, high accuracy and the like.
In another aspect of the invention, the invention also provides a method for detecting the insect erosion defect of the nut seeds. Referring to fig. 4, the method for detecting the erosion defect of the nut kernel according to the embodiment of the invention comprises the following steps:
s41: and acquiring an image to be detected of the material to be detected, wherein the image to be detected is an external rectangular X-ray image of the material to be detected.
S42: according to the image to be detected, carrying out center insect corrosion detection on the material to be detected, wherein the center insect corrosion detection comprises the following steps: sharpening, etching and binarizing the image to be detected to obtain a second binarized image, and judging whether the material to be detected has a center insect-etching defect or not according to the area of the inner contour in the second binarized image.
In the step, center insect-erosion detection is carried out on the material to be detected according to the image to be detected, if the center insect-erosion defect exists in the material to be detected, the insect-erosion defect exists in the material to be detected is determined, and the detection on the image to be detected can be finished. In the case where there is no center etch defect, S43 is performed.
It should be noted that the detected central erosion defect may be an external erosion defect of the nut kernel or an internal erosion defect of the nut kernel.
According to one implementation of the embodiment of the invention, after the material outline is acquired for the sharpened image, the outline can be internally filled with black and the black part is corroded, wherein the material outline is the outline corresponding to the largest connected domain in the image. In addition, after the outline of the material is acquired for the sharpened image, the outline can be internally filled with white, and the white part can be corroded. And (3) the outline of the corroded material is reduced, and a center area image corresponding to the outline of the corroded material is taken from the sharpened image to be detected. And (3) performing binarization processing on the image of the central area, extracting the inner outline of the central area, and performing central insect erosion judgment according to the area of the inner outline. Specifically, referring to fig. 5, fig. 5a is an image to be detected, fig. 5b is a sharpened image obtained by sharpening the image to be detected, fig. 5c is a corroded image obtained by filling black in the interior of a contour in the sharpened image and corroding a black part, and fig. 5d is a binarized image obtained by binarizing the sharpened image according to the corroded contour of the material.
Therefore, by adopting corrosion treatment in the center insect corrosion detection, the interference of external insect corrosion defects possibly existing in the material to be detected can be effectively avoided. Further, taking out a sharpened image of the central area according to the sharpened image and the corroded material outline, carrying out binarization processing on the sharpened image, filling all images outside the central area into colors different from the inner outline in the central area, if the area in the inner outline is white and the rest is black, or the area in the inner outline is black and the rest is white, obtaining the area closest to the central insect corrosion, namely the area of the inner outline, namely the area aiming at the binarized central area image, and acquiring the area of the internal communication area, and if the area is within a preset area threshold range of the central insect corrosion defect, confirming that the area is the central insect corrosion defect.
S43: according to the image to be detected, carrying out external insect corrosion detection on the material to be detected, wherein the external insect corrosion detection comprises the following steps: sequentially performing binarization processing and convex hull processing on the image to be detected to respectively obtain a first binarization image and a first convex hull image, and subtracting the first convex hull image from the first binarization image to obtain a concave area; judging whether the material to be detected has external insect-erosion defects or not according to the area of the concave area.
S41 is the same as S11, S43 is the same as S12, and the explanation of S41 and S43 will be referred to the corresponding parts and will not be repeated here.
The method comprises the steps of firstly carrying out center worm corrosion detection, detecting the internal worm corrosion defect and the external worm corrosion defect of the nut kernel, and carrying out external worm corrosion defect detection when the result of the center worm corrosion detection is that the worm corrosion defect does not exist. The combination of the two can effectively detect the internal insect-erosion defect and the external insect-erosion defect of the nut kernels, and the detection is more comprehensive and the detection accuracy is higher.
In another aspect of the invention, the invention also provides a method for detecting the insect erosion defect of the nut seeds. Referring to fig. 6, the method includes:
s61: and acquiring an image to be detected of the material to be detected, wherein the image to be detected is an external rectangular X-ray image of the material to be detected.
S62: and judging whether adhesion exists in the materials to be detected in the images to be detected, and if the adhesion does not exist, executing S63.
Specifically, the step of judging whether adhesion exists in the material to be detected in the image to be detected comprises the following steps: if the size of the circumscribed rectangular X-ray image of the material to be detected exceeds a preset size threshold, judging that the material to be detected is adhered; otherwise, judging that the material to be detected is not adhered. The above-mentioned dimensions refer to at least one of the length, width and area of the circumscribed rectangular X-ray image, i.e. the image to be detected. For example, the sizes used for judging adhesion include length, width and area, if the length, width and area of the circumscribed rectangular X-ray image exceed the corresponding length threshold value, width threshold value and area threshold value, the adhesion of the material to be detected is judged, otherwise, the material to be detected is judged not to be adhered. The preset size threshold is set according to the size of the material to be detected, for example, for the badam kernel, the length and width of the badam kernel in imaging can be set according to the free placement of the badam kernel.
S63: according to the image to be detected, carrying out center insect corrosion detection on the material to be detected, wherein the center insect corrosion detection comprises the following steps: sharpening, etching and binarizing the image to be detected to obtain a second binarized image, and judging whether the material to be detected has a center insect-etching defect or not according to the area of the inner contour in the second binarized image. In the case where there is no center etch defect, S64 is performed.
S64: according to the image to be detected, carrying out external insect corrosion detection on the material to be detected, wherein the external insect corrosion detection comprises the following steps: sequentially performing binarization processing and convex hull processing on the image to be detected to respectively obtain a first binarization image and a first convex hull image, and subtracting the first convex hull image from the first binarization image to obtain a concave area; judging whether the material to be detected has external insect-erosion defects or not according to the area of the concave area.
S61 is the same as S11, S63 is the same as S42, S64 is the same as S12, and the explanation of S61, S63 and S64 will be referred to the corresponding parts and will not be repeated here.
According to the method, adhesion judgment is carried out on intercepted materials, central insect-erosion detection is carried out firstly for materials to be detected without adhesion, internal insect-erosion defects and external insect-erosion defects of nut kernels can be detected, and when the insect-erosion detection result of the central insect-erosion is that the insect-erosion defects are not existed, external insect-erosion defect detection is carried out. The setting not only can reduce the erroneous judgement that leads to because of the material adhesion like this, adopts the center worm to erode and detects and detect the mode that both combine with outside worm to erode, can effectually detect out the inside worm of nut seed benevolence and erode the defect with outside worm, detects more comprehensively and detects the accuracy higher.
In another aspect of the invention, the invention also provides a method for detecting the insect erosion defect of the nut seeds. Referring to fig. 7, according to an embodiment of the present invention, the method includes:
s71: and obtaining a pre-detection image of the material to be detected, wherein the pre-detection image is an external rectangular X-ray image of the material to be detected.
In the step, an X-ray image of a material to be detected is acquired through an imaging device of X-ray detection equipment, the material to be detected is intercepted by utilizing an external rectangle aiming at the material to be detected in the X-ray image, and a pre-detection image is obtained. According to some embodiments of the present invention, a method for intercepting a material to be detected by using an external rectangle comprises: firstly, performing binarization processing on an obtained X-ray image, then extracting the outline of a material to be detected, obtaining a rectangle along the edge of the outline, and performing amplification processing (for example, widening each side by 2-8 pixels) on each side of the rectangle to obtain the external rectangle, and intercepting the material to be detected from the X-ray image by using the external rectangle. By adopting the method, the image to be detected of the material to be detected is obtained by utilizing the external rectangle, the interference of other materials can be effectively eliminated, and the erroneous judgment caused by the adhesion of the materials is reduced.
S72: judging whether adhesion exists in the materials to be detected in the pre-detected image, and if the adhesion exists, executing a subsequent step S73.
Specifically, the step of judging whether adhesion exists in the material to be detected in the image to be detected comprises the following steps: if the size of the circumscribed rectangular X-ray image of the material to be detected exceeds a preset size threshold, judging that the material to be detected is adhered; otherwise, judging that the material to be detected is not adhered. The above-mentioned dimensions refer to at least one of the length, width and area of the circumscribed rectangular X-ray image, i.e. the image to be detected. For example, the sizes used for judging adhesion include length, width and area, if the length, width and area of the circumscribed rectangular X-ray image exceed the corresponding length threshold value, width threshold value and area threshold value, the adhesion of the material to be detected is judged, otherwise, the material to be detected is judged not to be adhered.
According to some embodiments of the invention, the long threshold of the circumscribed rectangular X-ray image may be 60-70 pixels and the wide threshold of the circumscribed rectangular X-ray image may be 60-70 pixels.
S73: and cutting the material to be detected in the pre-detected image, and intercepting the external rectangular X-ray image of the material to be detected again to obtain the image to be detected.
Segmenting a material to be detected in a pre-detected image, including: and performing binarization treatment, corrosion treatment and expansion treatment on the image to be detected. Specifically, binarizing the pre-detection image to obtain a binarized image; and (3) acquiring the outline of the largest connected domain in the binarized image, filling white or black in the outline area, carrying out corrosion treatment on the black area or the white area, acquiring the corroded outline, carrying out expansion treatment on the corroded outline, acquiring the expanded outline, acquiring the external rectangle of the expanded outline, and intercepting the area corresponding to the expanded outline in the pre-detected image by utilizing the external rectangle, namely intercepting the image to be detected again. Referring to fig. 10, fig. 10a is a pre-detected image in which material adhesion exists, fig. 10b is a rectangle obtained by performing corrosion and expansion treatment on the pre-detected image, and small frames in fig. 10c are re-truncated rectangles, wherein the frames are selected as the pre-detected image, and it is understood that after the segmentation, the number of the possibly pre-detected images may be increased, and then a plurality of the pre-detected images may be processed respectively.
According to some embodiments of the present invention, the erosion radius used in the erosion image may be 0 to 30, and the parameters used in the expansion include the expansion radius, i.e. how many turns to expand, which is to obtain a segmented rectangular frame, with a value of about 40.
S74: and judging whether the material to be detected is split according to the image to be detected, and if so, executing S75.
The step of judging whether the material to be detected is divided comprises the following steps: if the size of the circumscribed rectangular X-ray image of the material to be detected exceeds a preset size threshold, judging that the material to be detected is not separated, namely the material to be detected in the image to be detected still has adhesion; otherwise, judging that the material to be detected is separated, namely that the material to be detected in the image to be detected is not adhered. The above-mentioned dimensions refer to at least one of the length, width and area of the circumscribed rectangular X-ray image, i.e. the image to be detected. For example, the size used for judging adhesion comprises length, width and area, if the length, width and area of the circumscribed rectangular X-ray image exceed the corresponding length threshold value, width threshold value and area threshold value, the material to be detected is judged to be undivided, otherwise, the material to be detected in the image to be detected is judged to be divided.
S75: according to the image to be detected, carrying out external insect corrosion detection on the material to be detected, wherein the external insect corrosion detection comprises the following steps: sequentially performing binarization processing and convex hull processing on the image to be detected to respectively obtain a first binarization image and a first convex hull image, and subtracting the first convex hull image from the first binarization image to obtain a concave area; judging whether the material to be detected has external insect-erosion defects or not according to the area of the concave area.
S75 is the same as S12, and is not described herein, and specific explanation may refer to the corresponding parts. .
In the method, the intercepted materials are subjected to adhesion judgment, the adhered materials to be detected are subjected to segmentation treatment, and external insect corrosion defect detection is performed on the segmented materials. The setting can reduce misjudgment caused by material adhesion, the external rectangular X-ray image of the material to be detected is used as the image to be detected, whether the situation of mutual adhesion of nut seeds exists in the material to be detected is judged first, when the material to be detected is adhered, the image is divided, the divided image is used as the image to be detected, the concave area in the image to be detected is obtained through binarization processing and convex hull processing of the image to be detected, and whether the external insect corrosion defect exists in the material to be detected is judged according to the area of the concave area. The method has the advantages of high detection efficiency, high accuracy and the like.
In one implementation manner of the embodiment shown in fig. 7, the step of determining whether the material to be detected has an external insect-attack defect according to the area of the concave area may include: if the area is smaller than the first preset threshold value and the number of the concave areas larger than the second preset threshold value is preset, and the distance from the concave areas to the image boundary is larger than the preset distance threshold value, determining that the material to be detected has external insect-erosion defects.
The inventor finds in the study that if the obtained number of the concave areas is too large, such as more than 2, the concave areas may be caused by adhesion of materials to be detected; the obtained area of the concave area is overlarge, namely larger than or equal to a first preset threshold value, and the area is possibly caused by adhesion and undivided material to be detected; the obtained distance from the concave region to the image boundary is smaller than or equal to the preset distance threshold value, and the erroneous judgment of the boundary region is possible. Therefore, judging whether the material to be detected has the external insect-attack defect or not according to the area and the number of the concave areas and the distance from the concave areas to the image boundary can eliminate the situation that the erroneous judgment is possible, and the accuracy of detecting the external insect-attack defect is improved.
In another implementation manner of the embodiment shown in fig. 7, the step of determining whether the material to be detected has an external insect-attack defect according to the area of the concave area may include: if the number of the concave areas with the area smaller than the first preset threshold value and larger than the second preset threshold value is a preset number, determining that the material to be detected has external insect-erosion defects.
Judging whether the material to be detected has external insect-attack defects according to the area and the number of the concave areas can partially eliminate the situation that the error judgment possibly exists, and improves the accuracy of detecting the external insect-attack defects.
According to the embodiment of the present invention, if the judgment result in step S74 is that the material to be detected in the image to be detected is not separated, the image to be detected is directly used as the image to be detected to perform the center erosion detection, and the mode of performing the center erosion detection on the image to be detected in this step is the same as that in S42, and details thereof are not repeated herein, and specific reference may be made to the corresponding content.
In another aspect of the invention, the invention also provides a method for detecting the insect erosion defect of the nut seeds. Referring to fig. 8, according to an embodiment of the present invention, the method includes:
S81: and obtaining a pre-detection image of the material to be detected, wherein the pre-detection image is an external rectangular X-ray image of the material to be detected. S81 is the same as S71, and is not described herein, and specific reference may be made to the corresponding content.
S82: judging whether adhesion exists in the materials to be detected in the pre-detected image. In the step, judging whether adhesion exists in the materials to be detected in the pre-to-be-detected image; if there is sticking, the subsequent step S83 is performed. S82 is the same as S72, and is not described herein, and specific reference may be made to the corresponding content.
S83: and cutting the material to be detected in the pre-detected image, and intercepting the external rectangular X-ray image of the material to be detected again to obtain the image to be detected. S83 is the same as S73, and is not described herein, and specific reference may be made to the corresponding content.
S84: and judging whether the material to be detected is split according to the image to be detected, and if so, executing S85. S84 is the same as S74 described above, and details thereof will not be described herein, and reference is made to the corresponding descriptions above.
S85: sequentially performing binarization processing and convex hull processing on the image to be detected to respectively obtain a third binarization image and a second convex hull image, and subtracting the obtained second convex hull image from the third binarization image to obtain a first concave region; if the number of the first concave areas with the area larger than the second preset threshold is larger than the preset number, the line drawing processing is performed on the image to be detected, and S86 is performed.
Therefore, the embodiment of the invention carries out center insect-erosion defect detection and external insect-erosion defect detection on the image to be detected, processes the largest connected domain in the image to be detected, further divides a plurality of first concave areas in the image into a plurality of areas through line drawing, and can influence the subsequent detection result through line drawing processing, thereby further improving the accuracy of the detection result. As shown in fig. 11, fig. 11a is a segmented image to be detected, fig. 11b is a line-exchanged material image, and the largest connected domain in the line-drawn material image is processed when center insect-erosion detection and/or outer insect-erosion detection are performed subsequently.
According to an embodiment of the present invention, the line drawing process includes: and drawing a line on the minimum distance between the first concave area with the largest area and the first concave area with the next largest area.
Further, a second concave area after line drawing is obtained; judging whether the line drawing is successful or not according to the first concave area and the second concave area, if not, determining the distances among the vertexes of a plurality of second concave areas with the areas larger than a second preset threshold value, and drawing the line between the two vertexes corresponding to the minimum distance. Specifically, a plurality of second concave areas are obtained after the line is drawn; if the area of the second concave area is obviously changed relative to the first concave area, the line drawing is considered to be successful, and the line drawing is ended, for example, the area reduction amplitude of the second concave area exceeds the preset area proportion relative to the first concave area, or the number of the second concave areas exceeds the preset number proportion, and the line drawing is considered to be successful. And if the line drawing is unsuccessful, determining the distances among the vertexes of the plurality of second concave areas with the areas larger than a second preset threshold value, and carrying out the line drawing between the two vertexes corresponding to the minimum distance.
S86: according to the image to be detected, carrying out center insect corrosion detection on the material to be detected, wherein the center insect corrosion detection comprises the following steps: sharpening, etching and binarizing the image to be detected to obtain a second binarized image, and judging whether the material to be detected has a center insect-etching defect or not according to the area of the inner contour in the second binarized image. In the case where there is no center etch defect, S87 is executed again. The method for detecting the center worm corrosion of the image to be detected in this step is the same as S42, and details thereof will not be described herein, and reference may be made to the above corresponding content.
S87: according to the image to be detected, carrying out external insect corrosion detection on the material to be detected, wherein the external insect corrosion detection comprises the following steps: sequentially performing binarization processing and convex hull processing on the image to be detected to respectively obtain a first binarization image and a first convex hull image, and subtracting the first convex hull image from the first binarization image to obtain a concave area; judging whether the material to be detected has external insect-erosion defects or not according to the area of the concave area. The method for detecting the external insect corrosion of the image to be detected in this step is the same as S12, and details thereof are not described herein, and reference may be made to the above corresponding content.
According to the embodiment of the invention, if the first concave area is smaller than the first preset threshold and larger than the second preset threshold is a preset number of first concave areas, if the distance from the first concave area to the image boundary is larger than the preset distance threshold (i.e. not belonging to the boundary area misjudgment), the first concave area is determined to be an external insect-erosion defect, and the material to be detected is determined to have an external insect-erosion defect, otherwise, the center insect-erosion detection is performed on the material to be detected according to the image to be detected, and the mode of performing the center insect-erosion detection in this step is the same as that of S42 described above, and is not repeated here.
According to an embodiment of the present invention, the method may further include: by executing step S82, if there is no adhesion in the material to be detected in the pre-detected image, the pre-detected image is used as the image to be detected, and external insect corrosion detection is performed on the material to be detected according to the image to be detected. The external erosion detection in this step is the same as the above step S12, and will not be described here.
According to an embodiment of the present invention, the method may further include: by executing step S82, if there is no adhesion in the material to be detected in the pre-detected image, the pre-detected image is used as the image to be detected, and the center insect corrosion detection is performed on the material to be detected according to the image to be detected. The method for detecting the center worm corrosion in this step is the same as S42 described above, and will not be described here.
According to an embodiment of the present invention, the method may further include: by executing step S82, if there is no adhesion in the material to be detected in the image to be detected, the image to be detected is used as the image to be detected, and external insect-erosion detection is performed on the material to be detected according to the image to be detected, and one of the two detection modes of center insect-erosion detection is performed on the material to be detected according to the image to be detected, and when no corresponding defect is detected, the other detection mode is performed. Specifically, external insect-erosion detection can be performed on the material to be detected according to the image to be detected, and when the external insect-erosion defect is detected, the detection is finished, and the condition that the external insect-erosion defect exists in the material to be detected is judged; and when the external insect-erosion defect is not detected, further carrying out center insect-erosion detection on the material to be detected according to the image to be detected. Or firstly, carrying out center insect-erosion detection on the material to be detected according to the image to be detected, and judging that the material to be detected has the center insect-erosion defect after the detection is finished when the center insect-erosion defect is detected; and when the central insect-erosion defect is not detected, further carrying out external insect-erosion detection on the material to be detected according to the image to be detected. The specific operation methods of the external erosion detection and the central erosion detection are as described above, and are not described herein.
According to the method, adhesion judgment is carried out on intercepted materials, segmentation treatment is carried out on the adhered materials to be detected, whether line drawing treatment is carried out is determined according to the number and the area of the obtained first concave areas, and based on the line drawing treatment, center insect corrosion detection and external insect corrosion detection are sequentially carried out. The setting not only can reduce the erroneous judgement that leads to because of the material adhesion like this, adopts the center worm to erode and detects and detect the mode that both combine with outside worm to erode, can effectually detect out the inside worm of nut seed benevolence and erode the defect with outside worm, detects more comprehensively and detects the accuracy higher.
For ease of understanding, a nut kernel erosion defect detection method according to one specific example of the present invention is described below with reference to fig. 9:
s91: acquiring a pre-detection image of a material to be detected, wherein the pre-detection image is an external rectangular X-ray image of the material to be detected;
S92: judging whether the materials to be detected in the pre-detected image are adhered or not, if not, executing S93 to detect the center insect-erosion defect of the materials to be detected, and executing S94 to detect the outer insect-erosion defect of the materials to be detected under the condition that the center insect-erosion defect is not present; if blocking exists, S95 is performed.
S93: taking the pre-detected image as an image to be detected, and carrying out center insect-erosion detection on the material to be detected according to the image to be detected, wherein the center insect-erosion detection comprises: sharpening, etching and binarizing the image to be detected to obtain a second binarized image, and judging whether the material to be detected has a center insect-etching defect or not according to the area of the inner contour in the second binarized image.
S94: according to the image to be detected, carrying out external insect corrosion detection on the material to be detected, wherein the external insect corrosion detection comprises the following steps: sequentially performing binarization processing and convex hull processing on the image to be detected to respectively obtain a first binarization image and a first convex hull image, and subtracting the first convex hull image from the first binarization image to obtain a concave area; judging whether the material to be detected has external insect-erosion defects or not according to the area of the concave area.
S95: and cutting the material to be detected in the pre-detected image, and intercepting the external rectangular X-ray image of the material to be detected again to obtain the image to be detected.
S96: and judging whether the material to be detected is split according to the image to be detected, if not, executing S97, and if so, executing S98.
S97: and carrying out center insect corrosion detection on the material to be detected according to the image to be detected, wherein the center insect corrosion detection comprises the following steps: sharpening, etching and binarizing the image to be detected to obtain a second binarized image, and judging whether the material to be detected has a center insect-etching defect or not according to the area of the inner contour in the second binarized image.
S98: sequentially performing binarization processing and convex hull processing on the image to be detected to respectively obtain a third binarization image and a second convex hull image, and subtracting the second convex hull image from the binarization image to obtain a second concave area;
If the number of the second concave regions with the area larger than the second preset threshold is larger than the preset number, S99 is executed, and if the number of the second concave regions with the area larger than the second preset threshold is larger than the preset number, S913 is executed.
S99: and carrying out line drawing treatment on the image to be detected.
S910: and carrying out center insect corrosion detection on the material to be detected according to the image to be detected, wherein the center insect corrosion detection comprises the following steps: sharpening, etching and binarizing the image to be detected to obtain a second binarized image, and judging whether the material to be detected has a center insect-etching defect or not according to the area of the inner contour in the second binarized image. In the case where there is no center etch defect, S911 is performed.
S911: according to the image to be detected, carrying out external insect corrosion detection on the material to be detected, wherein the external insect corrosion detection comprises the following steps: sequentially performing binarization processing and convex hull processing on the image to be detected to respectively obtain a first binarization image and a first convex hull image, and subtracting the first convex hull image from the first binarization image to obtain a concave area; judging whether the material to be detected has external insect-erosion defects or not according to the area of the concave area.
S912: according to the area of the first concave area, it is determined whether the material to be detected has an external insect-attack defect, and if not, S913 is performed.
S913: and carrying out center insect corrosion detection on the material to be detected according to the image to be detected, wherein the center insect corrosion detection comprises the following steps: sharpening, etching and binarizing the image to be detected to obtain a second binarized image, and judging whether the material to be detected has a center insect-etching defect or not according to the area of the inner contour in the second binarized image.
In the method, the intercepted materials are subjected to adhesion judgment, the adhered materials to be detected are subjected to segmentation treatment, whether line drawing treatment is performed or not is determined according to the number and the area of the obtained first concave areas, and based on the line drawing treatment, how to select judgment is then determined. Aiming at the situation that no adhesion exists, at least one of two modes of external insect corrosion detection of the center insect corrosion detection box can be carried out, so that misjudgment caused by material adhesion can be reduced, the detection is more comprehensive, and the accuracy is higher.
It should be noted that, in any of the above embodiments, the threshold value range adopted in the binarization processing may be 180-200, the preset area threshold value of the central worm-corrosion defect may be 15-20, the preset distance threshold value may be 1-2 pixels, the preset number may be 1, more than the preset number may be more than 1, that is, not less than 2, and the rest threshold values and the preset values may be set according to actual expectations of the results or according to the feedback results.
In addition, the detection method, the determination method, the step, etc. described in the above specific examples are as described above, and are not described herein.
Based on the same inventive concept as the above method embodiment, the embodiment of the present invention further provides a nut kernel erosion defect detection device, referring to fig. 12, the device includes:
The image acquisition module 121 is configured to acquire an image to be detected, where the image to be detected is an external rectangular X-ray image of a material to be detected;
The external worm corrosion detection module 122 is configured to perform external worm corrosion detection on the material to be detected according to the image to be detected, where the external worm corrosion detection includes: sequentially performing binarization processing and convex hull processing on the image to be detected to respectively obtain a first binarization image and a convex hull image, and subtracting the convex hull image from the first binarization image to obtain a concave area; judging whether the material to be detected has external insect-corrosion defects or not according to the area of the concave area.
In one implementation manner of this embodiment, the apparatus further includes a central worm erosion detection module.
The center worm corrosion detection module is used for carrying out center worm corrosion detection on the material to be detected according to the image to be detected, and the center worm corrosion detection comprises: sharpening, corroding and binarizing the image to be detected to obtain a second binarized image, and judging whether the material to be detected has a center insect-attack defect or not according to the area of the inner contour in the second binarized image;
the external worm corrosion detection module 122 is specifically configured to perform external worm corrosion detection on the material to be detected according to the image to be detected when the detection result of the central worm corrosion detection module is that the central worm corrosion defect does not exist.
In one implementation manner of this embodiment, the external erosion detection module 122 is configured to determine, according to an area of the concave area, whether the material to be detected has an external erosion defect, including:
If the area is smaller than the first preset threshold value and the number of the concave areas larger than the second preset threshold value is a preset number, and the distance from the concave areas to the image boundary is larger than the preset distance threshold value, determining that the material to be detected has an external insect-erosion defect; or if the area is smaller than the first preset threshold value and the number of the concave areas larger than the second preset threshold value is a preset number, determining that the material to be detected has external insect-attack defects.
In one implementation of this embodiment, the apparatus further includes an adhesion judgment module;
Before the step of performing center worm corrosion detection on the material to be detected according to the image to be detected, the method further comprises the following steps:
the adhesion judging module is used for judging whether adhesion exists in the materials to be detected in the image to be detected;
The center worm corrosion detection module is used for carrying out center worm corrosion detection on the material to be detected according to the image to be detected, and comprises the following steps: and under the condition that adhesion does not exist, carrying out center insect corrosion detection on the material to be detected according to the image to be detected.
Based on the same inventive concept as the above method embodiment, the embodiment of the present invention further provides a nut kernel erosion defect detection device, referring to fig. 13, which includes:
The image acquisition module 131 is configured to acquire a pre-detection image of a material to be detected, where the pre-detection image is an external rectangular X-ray image of the material to be detected;
A first judging module 132, configured to judge whether adhesion exists in the material to be detected in the pre-to-be-detected image;
the segmentation module 133 is configured to segment the material to be detected in the pre-to-be-detected image when the judgment result of the first judgment module indicates that adhesion exists, and re-intercept the external rectangular X-ray image of the material to be detected to obtain the image to be detected;
A second judging module 134, configured to judge whether the material to be detected is split according to the image to be detected;
And an external insect-erosion detection module 135, configured to perform external insect-erosion detection on the material to be detected according to the image to be detected when the determination result of the second determination module is division, where the external insect-erosion detection includes: sequentially performing binarization processing and convex hull processing on the image to be detected to respectively obtain a first binarization image and a convex hull image, and subtracting the convex hull image from the first binarization image to obtain a concave area; judging whether the material to be detected has external insect-corrosion defects or not according to the area of the concave area.
In one implementation manner of this embodiment, the apparatus further includes a central worm erosion detection module.
The central worm corrosion detection module is configured to perform central worm corrosion detection on the material to be detected according to the image to be detected when the segmentation result of the segmentation module 133 is that the segmentation result is not segmentation, where the central worm corrosion detection includes: and carrying out sharpening treatment, corrosion treatment and binarization treatment on the image to be detected to obtain a second binarization image, and judging whether the material to be detected has a center insect-corrosion defect or not according to the area of the inner contour in the second binarization image.
In one implementation manner of this embodiment, the external erosion detection module 135 is configured to determine, according to the area of the concave area, whether the material to be detected has an external erosion defect, including:
If the area is smaller than the first preset threshold value and the number of the concave areas larger than the second preset threshold value is a preset number, and the distance from the concave areas to the image boundary is larger than the preset distance threshold value, determining that the material to be detected has an external insect-erosion defect; or if the area is smaller than the first preset threshold value and the number of the concave areas larger than the second preset threshold value is a preset number, determining that the material to be detected has external insect-attack defects.
In one implementation manner of this embodiment, the apparatus further includes a central worm erosion detection module.
The center worm corrosion detection module is used for carrying out center worm corrosion detection on the material to be detected according to the image to be detected, and the center worm corrosion detection comprises: sharpening, corroding and binarizing the image to be detected to obtain a second binarized image, and judging whether the material to be detected has a center insect-attack defect or not according to the area of the inner contour in the second binarized image;
The external worm-corrosion detection module 135 is configured to detect external worm-corrosion of the material to be detected according to the image to be detected, and specifically configured to detect external worm-corrosion of the material to be detected according to the image to be detected when the detection result of the central worm-corrosion detection module indicates that the central worm-corrosion defect does not exist.
Further, the device also comprises a first processing module, which is used for sequentially carrying out binarization processing and convex hull processing on the image to be detected under the condition that the material to be detected is divided, respectively obtaining a third binarization image and a second convex hull image, subtracting the second convex hull image from the third binarization image, and obtaining a first concave area;
and if the number of the first concave areas with the area larger than the second preset threshold value is larger than the preset number, carrying out line drawing on the image to be detected.
Further, the first processing module is further configured to determine that an external worm corrosion defect exists in the material to be detected if the distance from the first concave area to the image boundary is greater than a preset distance threshold and the area is less than a first preset threshold under the condition that the first concave area with the area greater than a second preset threshold is a preset number, and otherwise, perform the center worm corrosion detection on the material to be detected according to the image to be detected.
In one implementation manner of this embodiment, in the case that no adhesion exists, the external erosion detection module 135 is configured to take a pre-detected image as an image to be detected, and perform the external erosion detection on the material to be detected according to the image to be detected, or the central erosion detection module is configured to perform the central erosion detection on the material to be detected according to the image to be detected, where the central erosion detection includes: and carrying out sharpening treatment, corrosion treatment and binarization treatment on the image to be detected to obtain a second binarization image, and judging whether the material to be detected has a center insect-corrosion defect or not according to the area of the inner contour in the second binarization image.
Or alternatively
In the absence of sticking, the outer erosion detection module 135 and the center erosion detection module perform as follows: taking a pre-detected image as an image to be detected, carrying out external insect-erosion detection on the material to be detected according to the image to be detected, and carrying out center insect-erosion detection on the material to be detected according to the image to be detected, wherein one of the two detection modes is firstly executed, and when no corresponding defect is detected, the other detection mode is executed; wherein, the center worm corrosion detection includes: and carrying out sharpening treatment, corrosion treatment and binarization treatment on the image to be detected to obtain a second binarization image, and judging whether the material to be detected has a center insect-corrosion defect or not according to the area of the inner contour in the second binarization image.
In one implementation manner of the embodiment of the present invention, the segmentation module 133 is specifically configured to sequentially perform binarization processing, corrosion processing and expansion processing on the pre-detected image, so as to segment the material to be detected in the pre-detected image.
In one implementation manner of the embodiment of the present invention, the first processing module is specifically configured to draw a line on a minimum distance between the first concave area with the largest area and the first concave area with the second largest area.
In one implementation of the embodiment of the present invention, the first processing module is further configured to: acquiring a second concave area after line drawing;
Judging whether the line drawing is successful or not according to the first concave area and the second concave area, if not, determining the distances among the vertexes of a plurality of second concave areas with the areas larger than a second preset threshold value, and drawing the line between the two vertexes corresponding to the minimum distance.
In the embodiment of the present invention, the device portion corresponds to the method portion described above, and the related technical explanation of this portion may refer to the method embodiment portion described above, which is not described herein.
In the description of the present specification, a description referring to terms "one embodiment," "some embodiments," "examples," "specific examples," or "some examples," etc., means that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the present invention. In this specification, schematic representations of the above terms are not necessarily directed to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, the different embodiments or examples described in this specification and the features of the different embodiments or examples may be combined and combined by those skilled in the art without contradiction.
While embodiments of the present invention have been shown and described above, it will be understood that the above embodiments are illustrative and not to be construed as limiting the invention, and that variations, modifications, alternatives and variations may be made to the above embodiments by one of ordinary skill in the art within the scope of the invention.

Claims (15)

1. The method for detecting the insect erosion defect of the nut kernel is characterized by comprising the following steps of:
acquiring an image to be detected, wherein the image to be detected is an external rectangular X-ray image of a material to be detected;
according to the image to be detected, carrying out external insect-erosion detection on the material to be detected, wherein the external insect-erosion detection comprises: sequentially performing binarization processing and convex hull processing on the image to be detected to respectively obtain a first binarization image and a first convex hull image, and subtracting the first convex hull image from the first binarization image to obtain a concave area; judging whether the material to be detected has external insect-erosion defects or not according to the area of the concave area;
before the step of performing external insect-erosion detection on the material to be detected according to the image to be detected, the method further comprises the following steps:
And carrying out center insect corrosion detection on the material to be detected according to the image to be detected, wherein the center insect corrosion detection comprises the following steps: sharpening, corroding and binarizing the image to be detected to obtain a second binarized image, and judging whether the material to be detected has a center insect-attack defect or not according to the area of the inner contour in the second binarized image;
and performing external insect corrosion detection on the material to be detected according to the image to be detected, wherein the method comprises the following steps:
And under the condition that the central insect-erosion defect does not exist, carrying out external insect-erosion detection on the material to be detected according to the image to be detected.
2. The method of claim 1, wherein the step of determining whether the material to be detected has an external insect-attack defect according to the area of the concave region comprises:
if the area is smaller than the first preset threshold value and the number of the concave areas larger than the second preset threshold value is a preset number, and the distance from the concave areas to the image boundary is larger than the preset distance threshold value, determining that the material to be detected has an external insect-erosion defect;
Or alternatively, the first and second heat exchangers may be,
If the number of the concave areas with the area smaller than the first preset threshold value and larger than the second preset threshold value is a preset number, determining that the material to be detected has external insect-erosion defects.
3. The method of claim 1, wherein prior to the step of center worm etch detection of the material to be detected from the image to be detected, the method further comprises:
judging whether adhesion exists in the material to be detected in the image to be detected;
the step of carrying out center worm corrosion detection on the material to be detected according to the image to be detected comprises the following steps:
And under the condition that adhesion does not exist, carrying out center insect corrosion detection on the material to be detected according to the image to be detected.
4. The method for detecting the insect erosion defect of the nut kernel is characterized by comprising the following steps of:
Acquiring a pre-detection image of a material to be detected, wherein the pre-detection image is an external rectangular X-ray image of the material to be detected;
judging whether adhesion exists in the materials to be detected in the pre-to-be-detected image;
If adhesion exists, dividing the material to be detected in the pre-to-be-detected image, and intercepting the external rectangular X-ray image of the material to be detected again to obtain the image to be detected;
judging whether the material to be detected is divided according to the image to be detected;
if the division is carried out, carrying out external insect-erosion detection on the material to be detected according to the image to be detected, wherein the external insect-erosion detection comprises the following steps: sequentially performing binarization processing and convex hull processing on the image to be detected to respectively obtain a first binarization image and a first convex hull image, and subtracting the first convex hull image from the first binarization image to obtain a concave area; judging whether the material to be detected has external insect-erosion defects or not according to the area of the concave area;
before the step of performing external insect-erosion detection on the material to be detected according to the image to be detected, the method further comprises the following steps:
And carrying out center insect corrosion detection on the material to be detected according to the image to be detected, wherein the center insect corrosion detection comprises the following steps: sharpening, corroding and binarizing the image to be detected to obtain a second binarized image, and judging whether the material to be detected has a center insect-attack defect or not according to the area of the inner contour in the second binarized image;
and performing external insect corrosion detection on the material to be detected according to the image to be detected, wherein the method comprises the following steps:
And under the condition that the central insect-erosion defect does not exist, carrying out external insect-erosion detection on the material to be detected according to the image to be detected.
5. The method according to claim 4, wherein the method further comprises:
If the material to be detected is not divided, center worm corrosion detection is carried out on the material to be detected according to the image to be detected, and the center worm corrosion detection comprises: and carrying out sharpening treatment, corrosion treatment and binarization treatment on the image to be detected to obtain a second binarization image, and judging whether the material to be detected has a center insect-corrosion defect or not according to the area of the inner contour in the second binarization image.
6. The method of claim 4, wherein the step of determining whether the material to be detected has an external insect-attack defect according to the area of the recessed area comprises:
if the area is smaller than the first preset threshold value and the number of the concave areas larger than the second preset threshold value is a preset number, and the distance from the concave areas to the image boundary is larger than the preset distance threshold value, determining that the material to be detected has an external insect-erosion defect;
Or alternatively, the first and second heat exchangers may be,
If the number of the concave areas with the area smaller than the first preset threshold value and larger than the second preset threshold value is a preset number, determining that the material to be detected has external insect-erosion defects.
7. The method of claim 4, further comprising, prior to said center etch detection of said material to be detected from said image to be detected:
Sequentially performing binarization processing and convex hull processing on the image to be detected to respectively obtain a third binarization image and a second convex hull image, and subtracting the second convex hull image from the third binarization image to obtain a first concave region;
and if the number of the first concave areas with the area larger than the second preset threshold value is larger than the preset number, carrying out line drawing on the image to be detected.
8. The method of claim 7, wherein the method further comprises:
And under the condition that the first concave areas with the areas larger than the second preset threshold value are in a preset number, if the distance from the first concave areas to the image boundary is larger than the preset distance threshold value and the areas are smaller than the first preset threshold value, determining that the material to be detected has external insect-erosion defects, and if not, carrying out center insect-erosion detection on the material to be detected according to the image to be detected.
9. The method according to claim 4, wherein the method further comprises: if no adhesion exists, taking the pre-detected image as an image to be detected, and carrying out external insect-erosion detection on the material to be detected according to the image to be detected, or carrying out center insect-erosion detection on the material to be detected according to the image to be detected, wherein the center insect-erosion detection comprises: and carrying out sharpening treatment, corrosion treatment and binarization treatment on the image to be detected to obtain a second binarization image, and judging whether the material to be detected has a center insect-corrosion defect or not according to the area of the inner contour in the second binarization image.
10. The method according to claim 4, wherein the method further comprises: if no adhesion exists, taking the pre-detected image as an image to be detected, carrying out external insect-erosion detection on the material to be detected according to the image to be detected, and carrying out center insect-erosion detection on the material to be detected according to the image to be detected, wherein one of the two detection modes is executed firstly, and when no corresponding defect is detected, the other detection mode is executed; wherein, the center worm corrosion detection includes: and carrying out sharpening treatment, corrosion treatment and binarization treatment on the image to be detected to obtain a second binarization image, and judging whether the material to be detected has a center insect-corrosion defect or not according to the area of the inner contour in the second binarization image.
11. The method of claim 4, wherein the partitioning comprises: and sequentially performing binarization treatment, corrosion treatment and expansion treatment on the pre-to-be-detected image so as to divide the material to be detected in the pre-to-be-detected image.
12. The method of claim 8, wherein the line drawing process comprises: and drawing a line on the minimum distance between the first concave area with the largest area and the first concave area with the next largest area.
13. The method according to claim 12, wherein the method further comprises:
acquiring a second concave area after line drawing;
Judging whether the line drawing is successful or not according to the first concave area and the second concave area, if not, determining the distances among the vertexes of a plurality of second concave areas with the areas larger than a second preset threshold value, and drawing the line between the two vertexes corresponding to the minimum distance.
14. A nut kernel erosion defect detection device for implementing the nut kernel erosion defect detection method according to any one of claims 1 to 13, characterized by comprising:
the image acquisition module is used for acquiring an image to be detected, wherein the image to be detected is an external rectangular X-ray image of a material to be detected;
The external insect corrosion detection module is used for carrying out external insect corrosion detection on the material to be detected according to the image to be detected, and the external insect corrosion detection comprises: sequentially performing binarization processing and convex hull processing on the image to be detected to respectively obtain a first binarization image and a first convex hull image, and subtracting the first convex hull image from the first binarization image to obtain a concave area; judging whether the material to be detected has external insect-corrosion defects or not according to the area of the concave area.
15. The nut kernel erosion defect detection device of claim 14, comprising:
the image acquisition module is used for acquiring a pre-detection image of the material to be detected, wherein the pre-detection image is an external rectangular X-ray image of the material to be detected;
The first judging module is used for judging whether adhesion exists in the materials to be detected in the pre-to-be-detected image;
The segmentation module is used for segmenting the material to be detected in the pre-detection image when the judgment result of the first judgment module is that adhesion exists, and intercepting the external rectangular X-ray image of the material to be detected again to obtain the image to be detected;
The second judging module is used for judging whether the material to be detected is split according to the image to be detected;
And the external insect-erosion detection module is used for carrying out external insect-erosion detection on the material to be detected according to the image to be detected when the judgment result of the second judgment module is division, and the external insect-erosion detection comprises: sequentially performing binarization processing and convex hull processing on the image to be detected to respectively obtain a first binarization image and a first convex hull image, and subtracting the first convex hull image from the first binarization image to obtain a concave area; judging whether the material to be detected has external insect-corrosion defects or not according to the area of the concave area.
CN201911054851.3A 2019-10-31 2019-10-31 Nut kernel worm erosion defect detection method and device Active CN112819746B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911054851.3A CN112819746B (en) 2019-10-31 2019-10-31 Nut kernel worm erosion defect detection method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911054851.3A CN112819746B (en) 2019-10-31 2019-10-31 Nut kernel worm erosion defect detection method and device

Publications (2)

Publication Number Publication Date
CN112819746A CN112819746A (en) 2021-05-18
CN112819746B true CN112819746B (en) 2024-04-23

Family

ID=75851820

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911054851.3A Active CN112819746B (en) 2019-10-31 2019-10-31 Nut kernel worm erosion defect detection method and device

Country Status (1)

Country Link
CN (1) CN112819746B (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1995592A1 (en) * 2007-05-22 2008-11-26 Honeywell International Inc. Automated defect detection of corrosion or cracks using SAFT processed Lamb wave images
JP2010054292A (en) * 2008-08-27 2010-03-11 Jfe Steel Corp Method of measuring internal defect
CN106442525A (en) * 2016-08-30 2017-02-22 石河子大学 Online detecting method for wizened defects of insides of walnuts
CN106950253A (en) * 2017-03-31 2017-07-14 河南工业大学 A kind of grain injured kernel early detection method and device
WO2018159689A1 (en) * 2017-02-28 2018-09-07 地方独立行政法人神奈川県立産業技術総合研究所 Method for observing inner structure of ceramic, method for producing ceramic, analysis system, and system for producing ceramic
CN109598715A (en) * 2018-12-05 2019-04-09 山西镭谱光电科技有限公司 Material size online test method based on machine vision
CN109685760A (en) * 2018-11-05 2019-04-26 华中科技大学 A kind of SLM powder bed powder laying image convex closure depression defect detection method based on MATLAB

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1995592A1 (en) * 2007-05-22 2008-11-26 Honeywell International Inc. Automated defect detection of corrosion or cracks using SAFT processed Lamb wave images
JP2010054292A (en) * 2008-08-27 2010-03-11 Jfe Steel Corp Method of measuring internal defect
CN106442525A (en) * 2016-08-30 2017-02-22 石河子大学 Online detecting method for wizened defects of insides of walnuts
WO2018159689A1 (en) * 2017-02-28 2018-09-07 地方独立行政法人神奈川県立産業技術総合研究所 Method for observing inner structure of ceramic, method for producing ceramic, analysis system, and system for producing ceramic
CN106950253A (en) * 2017-03-31 2017-07-14 河南工业大学 A kind of grain injured kernel early detection method and device
CN109685760A (en) * 2018-11-05 2019-04-26 华中科技大学 A kind of SLM powder bed powder laying image convex closure depression defect detection method based on MATLAB
CN109598715A (en) * 2018-12-05 2019-04-09 山西镭谱光电科技有限公司 Material size online test method based on machine vision

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
Xian-Guo Li et al..Automatic Defect Detection Method for Belt Based on Its X-Ray Images.《2011 International Conference on Control,Automation and System Engineering(CASF).2011,全文. *
玉米定向精播种粒形态与品质动态检测方法;刘长青 等;《农业机械学报》;第2.1、2.2节 *
软X射线技术对核桃内部品质的无损检测研究;黄星奕 等;《食品工业科技》;第344-346页 *

Also Published As

Publication number Publication date
CN112819746A (en) 2021-05-18

Similar Documents

Publication Publication Date Title
CN115375676B (en) Stainless steel product quality detection method based on image recognition
CN108460757B (en) Mobile phone TFT-LCD screen Mura defect online automatic detection method
CN109377485A (en) A kind of instant noodles packaging defect machine vision detection method
CN115020267B (en) Semiconductor surface defect detection method
CN115880248B (en) Surface scratch defect identification method and visual detection equipment
CN114693610A (en) Welding seam surface defect detection method, equipment and medium based on machine vision
Said et al. Robust automatic void detection in solder balls
CN116468687A (en) Scratch defect detection method and device, storage medium and electronic equipment
CN117351019B (en) Welding defect detection method
CN110858395A (en) Method for detecting dirty yarn defect of coiled filament
CN108346138B (en) Surface defect detection method and system based on image processing
CN115294527B (en) Subway tunnel damage detection method based on computer vision
CN110060239B (en) Defect detection method for bottle opening of bottle
KR20180115645A (en) Apparatus for weld bead recognition of 2d image-based and soot removal method using the same
CN107993223A (en) Scratch detection method, apparatus and electronic equipment
CN104156702A (en) Mixed bean automatic classification and identification method
CN112819746B (en) Nut kernel worm erosion defect detection method and device
CN105825182A (en) Double analysis method of online glume-gaping seed rice identification
CN109934817B (en) Method for detecting malformation of external contour of fruit body
CN112819745B (en) Nut kernel center worm-eating defect detection method and device
CN109146871B (en) Crack identification method and device
CN107545560B (en) Method and device for detecting air bubbles on tire sidewall
CN112614146B (en) Method and device for judging chessboard calibration corner points and computer readable storage medium
KR101713001B1 (en) Metal panel detecting appratus by processing image for method same
CN109191439A (en) A kind of target workpiece surface knife mark defect inspection method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant