Search

CN-121746415-B - Self-adaptive adjustment method and system for detection threshold of optical image based on reinforcement learning

CN121746415BCN 121746415 BCN121746415 BCN 121746415BCN-121746415-B

Abstract

The invention relates to an adaptive adjustment method and an adaptive adjustment system for an optical image detection threshold based on reinforcement learning, belongs to the technical field of machine vision and intelligent detection, and solves the technical problems that in the existing industrial vision detection, the threshold depends on manual setting, the detection accuracy is reduced due to lack of adaptability, real-time optimization cannot be achieved, and the like. The method comprises the following steps of S1, collecting an original image of a measured object, S2, preprocessing the original image, S3, constructing a state vector based on multidimensional feature quantity, S4, outputting actions by a reinforcement learning strategy network, S5, updating and applying a detection threshold based on the actions, S6, calculating a detection quality evaluation index and a reward signal, and S7, performing network modeling training and parameter updating by the reinforcement learning strategy to form a threshold self-adaptive adjustment strategy. Compared with the prior art, the invention has the advantages of no dependence on manual setting, strong adaptability, high precision, real-time optimization, wide universality and the like.

Inventors

  • GUO TAISHAN
  • WANG MINGQUAN
  • SUN QIN
  • GUO SONGBO
  • GUO CHAOHUI
  • Liu Kangchi

Assignees

  • 中北大学

Dates

Publication Date
20260508
Application Date
20260228

Claims (7)

  1. 1. The self-adaptive adjustment method for the detection threshold of the optical image based on reinforcement learning is characterized by comprising the following steps: s1, collecting an original image of a measured object; s2, carrying out gray scale normalization, denoising and contrast enhancement treatment on the original image to obtain a preprocessed image; s3, extracting a multidimensional feature quantity based on the preprocessed image, and carrying out normalization and vectorization on the multidimensional feature quantity to construct a state vector at the current moment; the multi-dimensional feature includes a global gray level histogram Local area variance Gradient amplitude distribution Edge pixel density And saturation ratio of highly reflective regions ; S4, the reinforcement learning strategy network receives the state vector in the step S3 and outputs actions; S5, updating a detection threshold based on the action, and applying the updated threshold parameter to the preprocessed image to obtain a detection result image; s6, calculating a detection quality evaluation index and a reward signal based on the detection result image; By passing through Calculating the evaluation index of the detection quality , 、 、 As the weight coefficient of the light-emitting diode, For measuring the accuracy and completeness of the segmentation of the target region, For measuring the continuity and positioning accuracy of edge detection, For measuring the false detection degree of noise or false edges; By passing through Calculating a reward signal , In order to smooth the penalty coefficient, For updated threshold parameters For detecting the vector, t is the time t; S7, strengthening learning strategy network modeling training and parameter updating, and forming a threshold self-adaptive adjustment strategy after continuous parameter updating.
  2. 2. The method for adaptively adjusting the detection threshold of the optical image based on reinforcement learning according to claim 1, wherein in the step S5: Based on Obtaining updated threshold parameters T is the time t, In order to detect the vector quantity, , , In order to act on the device, , For a pre-designed set of discrete or finite continuous actions, , For the global binarization threshold value, For a locally adaptive threshold window size, For the edge detection operator threshold value, Is a sharpening intensity coefficient; The updated threshold parameters Application to pre-processed images Image segmentation, edge detection and defect recognition are carried out to obtain a detection result image T is the detection time or the t frame image, Is the pixel coordinates in the image.
  3. 3. The method for adaptively adjusting the detection threshold of the optical image based on reinforcement learning according to claim 2, wherein in the step S7: Definition of the definition Is in state of Execute action downwards The obtained estimated value of the long-term accumulated return meets the following conditions , Is the state vector at the time t, M is the dimension of the state, , As a discount factor, the number of times the discount is calculated, All candidate actions in the next state; Defining a time sequence differential error as ; Will carry the parameter vector Is a function of (2) Updating according to the time sequence difference error, thereby meeting the following requirements , In order for the rate of learning to be high, For the function pair parameter vector And (3) forming a threshold self-adaptive adjustment strategy after continuous parameter updating.
  4. 4. An adaptive adjustment system for an optical image detection threshold based on reinforcement learning, characterized in that the system is used for the adaptive adjustment method for the optical image detection threshold based on reinforcement learning according to any one of claims 1 to 3, and the system comprises: the optical imaging module is used for acquiring an original image of the measured object; the image preprocessing module is used for carrying out gray scale normalization, denoising and contrast enhancement processing on the original image; the construction state vector module is used for extracting multidimensional feature quantities and constructing state vectors; The output action module is used for enabling the reinforcement learning strategy network to output actions; The threshold execution module is used for updating the threshold parameters; The detection evaluation module is used for generating a reward signal and judging a detection effect; the system comprises a reinforcement learning strategy network modeling training and parameter updating module, wherein the reinforcement learning strategy network modeling training and parameter updating module is used for forming a threshold self-adaptive adjustment strategy after continuous parameter updating.
  5. 5. The adaptive adjustment system for detecting threshold value of optical image based on reinforcement learning according to claim 4, wherein the adaptive adjustment strategy for threshold value is characterized in that when the threshold value is selected to cause detection result to approach to real boundary or to separate defect area, the system obtains positive rewards, when the threshold value is selected to cause edge fracture, over-segmentation or omission, punishment is given, continuous rewards are fed back, and the optimal mapping between threshold value and image characteristic under different optical conditions is learned by reinforcement learning strategy network to form the adaptive adjustment strategy for threshold value.
  6. 6. The adaptive adjustment system for detecting threshold of optical image based on reinforcement learning according to claim 5, wherein the reinforcement learning strategy network comprises a state coding layer, a feature fusion layer and an action decision layer, the state coding layer is used for carrying out feature extraction and compression representation on multi-dimensional feature quantities, the feature fusion layer is used for synthesizing image state information of different dimensions, and the action decision layer is used for outputting estimated values or action probability distribution of threshold adjustment actions.
  7. 7. The adaptive adjustment system for detecting threshold of optical image based on reinforcement learning according to claim 4, wherein the threshold execution module comprises a threshold buffer unit, an edge operator parameter updating unit and a preprocessing parameter synchronizing unit, the threshold buffer unit is used for storing and smoothing the threshold adjustment result and providing stable threshold parameters between adjacent detection periods, the edge operator parameter updating unit is used for updating the response threshold or operator parameter of the edge detection operator according to the threshold adjustment result and adjusting the sensitivity and positioning accuracy of the edge detection operator, and the preprocessing parameter synchronizing unit is used for synchronizing the updated threshold parameter with parameters in the image preprocessing process so as to keep the image preprocessing, threshold segmentation and edge detection processes consistent.

Description

Self-adaptive adjustment method and system for detection threshold of optical image based on reinforcement learning Technical Field The invention belongs to the technical field of machine vision and intelligent detection, and particularly relates to an adaptive adjustment method and system for an optical image detection threshold based on reinforcement learning. Background With the continuous improvement of automation and informatization level of industrial manufacturing processes, machine vision-based detection technology has been widely applied to various production scenes such as metal processing, electronic packaging, textile materials, semiconductor manufacturing, food packaging and the like. The industrial vision detection generally acquires the surface image of the workpiece through a camera, and performs the steps of preprocessing, segmentation, feature extraction, classification judgment and the like to realize the tasks of surface defect identification, size detection, assembly quality judgment, structure contour positioning and the like. In order to ensure the accuracy and stability of the detection result, the vision system often depends on a large number of manually set parameters including a brightness threshold, a texture contrast threshold, an edge response threshold, a binarization threshold, a filtering kernel scale, a segmentation region threshold, and the like. These thresholds and parameters are highly sensitive to ambient light, material reflectivity, texture complexity and equipment position changes, and need to be frequently adjusted in the actual production process, otherwise, problems such as false detection, omission, positioning offset and boundary blurring are easily caused. Existing industrial vision systems commonly employ fixed threshold or heuristic-based parameter adjustment. The fixed threshold is used for a long time after a group of global thresholds are set according to manual experience, and when the environment changes such as illumination change, lens focal length fine adjustment, batch difference of surface materials or dust particle shielding, the static thresholds cannot be reliably adapted to new conditions, so that the detection precision is obviously reduced. Another class of methods employs adaptive thresholding algorithms based on statistical features or gradient changes, such as Otsu thresholding, local adaptive thresholding, or histogram-based dynamic thresholding. These methods typically rely on a fixed mathematical model that cannot be optimized in real time based on the complexity of a particular production line. For example, under the scenes of strong reflective metal, low contrast surface, small-size defect detection and the like, the conventional self-adaptive algorithm is easy to have the problems of excessive deviation of threshold value or unstable oscillation, so that the detection result is discontinuous or error is accumulated. Disclosure of Invention In order to overcome the defects of the prior art and solve the technical problems that the detection accuracy is reduced and real-time optimization cannot be performed due to the fact that the threshold value is manually set and lack of adaptability in the existing industrial vision detection, the invention provides an optical image detection threshold value self-adaptive adjustment method and system based on reinforcement learning. The invention is realized by the following technical scheme. The invention provides an adaptive adjustment method for an optical image detection threshold based on reinforcement learning, which comprises the following steps: s1, collecting an original image of a measured object; s2, carrying out gray scale normalization, denoising and contrast enhancement treatment on the original image to obtain a preprocessed image; s3, extracting a multidimensional feature quantity based on the preprocessed image, and carrying out normalization and vectorization on the multidimensional feature quantity to construct a state vector at the current moment; s4, the reinforcement learning strategy network receives the state vector in the step S3 and outputs actions; S5, updating a detection threshold based on the action, and applying the updated threshold parameter to the preprocessed image to obtain a detection result image; s6, calculating a detection quality evaluation index and a reward signal based on the detection result image; S7, strengthening learning strategy network modeling training and parameter updating, and forming a threshold self-adaptive adjustment strategy after continuous parameter updating. Further, the multi-dimensional feature in step S3 includes a global gray level histogramLocal area varianceGradient amplitude distributionEdge pixel densityAnd saturation ratio of highly reflective regions。 Further, in the step S5: Based on Obtaining updated threshold parametersT is the time t,In order to detect the vector quantity,,,In order to act on the device,,For a pre-designe