Search

CN-121999029-A - Wheat impurity area detection method and system based on improvement YOLOv-seg

CN121999029ACN 121999029 ACN121999029 ACN 121999029ACN-121999029-A

Abstract

The invention discloses a wheat impurity area detection method and a system based on improved YOLOv-seg, and relates to the technical field of detection, wherein the method comprises the steps of labeling an original image to generate a label, and then preprocessing to obtain a sample image data set; the method comprises the steps of training and improving YOLOv n-seg models through sample image data sets, obtaining a trained wheat impurity identification model, obtaining an original image of the wheat to be detected, carrying out impurity identification through the wheat impurity identification model, obtaining an identification result, carrying out morphological closing operation and contour optimization on the identification result, calculating impurity pixel areas and the proportion of the impurity pixel areas in the whole image based on the optimized identification result, and generating an impurity content report based on the impurity pixel areas and the proportion of the impurity pixel areas in the whole image. The method realizes accurate calculation of millimeter-level impurities in a complex scene and provides an efficient and reliable technical scheme for wheat quality inspection.

Inventors

  • MAO BO
  • ZHANG LEI
  • LI LIUBIN
  • Wang Shanqun
  • Xing Huizhen
  • XU RUISONG
  • HE RONG
  • WANG ZHIGAO
  • CHEN YANBO
  • LU YANG
  • CHEN XIANG
  • LI JINHAO
  • SHEN FEI

Assignees

  • 南京财经大学

Dates

Publication Date
20260508
Application Date
20260409

Claims (7)

  1. 1. The wheat impurity area detection method based on the improvement YOLOv-seg is characterized by comprising the following steps of: S1, collecting wheat and impurity samples, and establishing an original image; s2, labeling the original image to generate a label, and preprocessing to obtain a sample image dataset; S3, training and improving YOLOv n-seg models through the sample image data set to obtain a trained wheat impurity identification model; S4, acquiring an original image of the wheat to be detected, and carrying out impurity recognition through the wheat impurity recognition model to acquire a recognition result; S5, morphological closing operation and contour optimization are carried out on the identification result, and the area of the impurity pixel and the duty ratio in the whole image are calculated based on the optimized identification result; and S6, generating an impurity content report based on the impurity pixel area and the duty ratio in the whole image.
  2. 2. The method for detecting the area of the wheat impurity based on the improvement YOLOv-seg according to claim 1, wherein the step S1 specifically comprises the steps of collecting wheat and an impurity sample, adopting a ring-shaped light source and backlight to combine and illuminate on a background cloth with black background, and acquiring an original image by using an industrial camera with resolution not lower than 600 ten thousand pixels.
  3. 3. The wheat impurity area detection method based on the improvement YOLOv-seg according to claim 1, wherein the pretreatment in S2 specifically includes: Space transformation enhancement, namely performing vertical overturning and horizontal overturning with 50% probability, performing +/-10 DEG random rotation with 50% probability, and filling a blank area with black after rotation; The color and illumination enhancement, namely, adjusting the brightness and contrast with 50% probability, wherein the adjustment range is +/-25%, and the 60% probability carries out fine adjustment on the hue, saturation and brightness of the HSV space; Noise simulation enhancement, randomly applying gaussian blur, median blur or motion blur with 30% probability; Marking data adaptation rules, namely normalizing coordinates of a boundary box by using a YOLO format, setting a minimum visibility threshold value to be 0.2 and setting a minimum area to be 100 pixels to filter invalid boxes, recording key points by using absolute pixel coordinates, and reserving class labels without exceeding points in an image range.
  4. 4. The wheat impurity area detection method based on the improvement YOLOv-seg is characterized in that the improvement YOLOv n-seg model specifically comprises the steps of embedding EABiFPN modules in Neck parts on the basis of an original YOLOv n model, realizing multi-level feature interaction through bidirectional cross-scale connection, adding Sobel edge compensation branches before P2/P3 layer input, specifically comprising the steps of extracting horizontal and vertical gradients by adopting a Sobel operator, carrying out channel attention weighted fusion with original features after L2 normalization and Sigmoid activation, inserting DECA modules in front of each detection head, adopting a channel branch and space branch dual-path structure, and realizing space-channel collaborative enhancement through dynamic gate fusion weighted by leavable parameters alpha and beta.
  5. 5. The wheat impurity area detection method based on the improvement YOLOv-seg according to claim 1, wherein the morphological closing operation and the contour optimization of the identification result specifically comprise the steps of performing the morphological closing operation by using a 5×5 ellipse checking mask, filling small holes and smoothing the contour, simplifying the contour by using a Douglas-Peucker algorithm, setting the tolerance epsilon to be 0.5% of the contour circumference, converting integer coordinates into floating point coordinates to support sub-pixel precision processing, and converting the area calculation into physical dimensions according to a preset scale.
  6. 6. The method for detecting the area of the wheat impurity based on the improvement YOLOv-seg according to claim 5, wherein the contour optimization further comprises sub-pixel precision conversion, the conversion of integer coordinates into floating point coordinates is performed to simplify Douglas-Peucker, and the area calculation scales the physical size in proportion.
  7. 7. A wheat impurity area detection system based on the improvement YOLOv-seg, applying the wheat impurity area detection method based on the improvement YOLOv-seg according to any one of claims 1-6, characterized by comprising: the image acquisition unit comprises a marked background cloth, an annular light source, a backlight source and an industrial camera and is used for establishing an original image; A processing host, carrying an improvement YOLOv n-seg model, comprising: EABiFPN processing module for realizing feature pyramid bidirectional fusion and edge compensation; a DECA attention module for performing space-channel collaborative feature enhancement; The post-processing unit is configured with morphological closing operation and a Douglas-Peucker contour optimization algorithm; and the area calculation unit is used for counting the impurity pixel ratio based on the optimized mask and outputting a content report.

Description

Wheat impurity area detection method and system based on improvement YOLOv-seg Technical Field The invention relates to the technical field of detection, in particular to a wheat impurity area detection method and system based on improvement YOLOv-seg. Background The quality inspection of wheat is the first gateway before the storage of wheat, and accurate judgment of the quality of wheat is the basis for ensuring the storage safety and scientific management. The impurity content (cobble, straw, etc.) is one of the important indexes for evaluating the quality grade of wheat, and the grade of the impurity directly influences the purchase price and the subsequent processing quality of the wheat. At present, the wheat impurity detection mainly depends on an artificial sense method or a traditional mechanical screening weighing method, wherein the artificial sense method has low efficiency, long time consumption and is easily influenced by subjective factors, so that the detection accuracy is unstable, the mechanical screening method can quantify the total impurity quality, but cannot obtain the spatial distribution and the morphological information of the impurities, the impurity types are difficult to distinguish, and the requirements of modern storage on visual and fine management cannot be met. In addition, the traditional algorithm has weaker edge segmentation capability on impurities, is difficult to accurately calculate the actual area ratio of the impurities, has higher demand on calculation resources, and is difficult to deploy at the edge end in real time. Therefore, how to realize high-precision division of the impurity profile and rapidly estimate the area ratio of the impurity in the wheat is a technical problem to be solved by those skilled in the art. Disclosure of Invention In view of the above, the invention provides a wheat impurity area detection method and a system based on the improvement YOLOv-seg, which realize high-precision segmentation of impurity profile and rapidly estimate the wheat impurity of impurity area ratio. In order to achieve the above purpose, the present invention adopts the following technical scheme: a wheat impurity area detection method based on improvement YOLOv-seg comprises the following steps: S1, collecting wheat and impurity samples, and establishing an original image; s2, labeling the original image to generate a label, and preprocessing to obtain a sample image dataset; S3, training and improving YOLOv n-seg models through the sample image data set to obtain a trained wheat impurity identification model; S4, acquiring an original image of the wheat to be detected, and carrying out impurity recognition through the wheat impurity recognition model to acquire a recognition result; S5, morphological closing operation and contour optimization are carried out on the identification result, and the area of the impurity pixel and the duty ratio in the whole image are calculated based on the optimized identification result; and S6, generating an impurity content report based on the impurity pixel area and the duty ratio in the whole image. Preferably, the step S1 specifically comprises the steps of collecting wheat and impurity samples, adopting a ring-shaped light source and backlight to combine and illuminate on a background cloth with black background, and acquiring an original image by using an industrial camera with resolution not lower than 600 ten thousand pixels. Preferably, the preprocessing in S2 specifically includes: Space transformation enhancement, namely performing vertical overturning and horizontal overturning with 50% probability, performing +/-10 DEG random rotation with 50% probability, and filling a blank area with black after rotation; The color and illumination enhancement, namely, adjusting the brightness and contrast with 50% probability, wherein the adjustment range is +/-25%, and the 60% probability carries out fine adjustment on the hue, saturation and brightness of the HSV space; Noise simulation enhancement, randomly applying gaussian blur, median blur or motion blur with 30% probability; Marking data adaptation rules, namely normalizing coordinates of a boundary box by using a YOLO format, setting a minimum visibility threshold value to be 0.2 and setting a minimum area to be 100 pixels to filter invalid boxes, recording key points by using absolute pixel coordinates, and reserving class labels without exceeding points in an image range. Preferably, the improved YOLOv n-seg model specifically comprises the steps of embedding EABiFPN a module in Neck on the basis of an original YOLOv n model, realizing multi-level feature interaction through bidirectional cross-scale connection, adding a Sobel edge compensation branch before P2/P3 layer input, specifically adopting a Sobel operator to extract horizontal and vertical gradients, carrying out channel attention weighted fusion with original features after L2 normalization and Sigmoid activation