A valve surface defect detection method and system based on machine vision

By verifying the integrity of the valve visual image and fitting curves, a detection code is generated and the region is divided, which solves the problem of insufficient accuracy in the detection of valve surface defects in the existing technology and realizes high-precision defect identification.

CN122335849APending Publication Date: 2026-07-03HEBEI FANSEN METAL TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HEBEI FANSEN METAL TECHNOLOGY CO LTD
Filing Date
2026-05-20
Publication Date
2026-07-03

AI Technical Summary

Technical Problem

Existing technologies suffer from problems such as incomplete images, incomplete capture, and blurring/distortion, which cause valve surface defect detection to fail, making it impossible to accurately identify minor defects and resulting in insufficient recognition accuracy.

Method used

By performing integrity verification on the visual images of valves, constructing an image coordinate system and performing curve fitting, removing pixels that do not conform to the image, generating detection codes and dividing regions, and using association rule algorithms to determine detection scores, the fine-grained distinction of defects is achieved.

Benefits of technology

It improves the stability and reliability of valve surface defect detection, accurately identifies defects such as corrosion and fatigue cracking, avoids missed detections and false detections, and meets the precision requirements of valve defect detection in the industrial field.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122335849A_ABST
    Figure CN122335849A_ABST
Patent Text Reader

Abstract

This invention relates to the field of valve inspection technology, and discloses a method and system for detecting valve surface defects based on machine vision. The method includes: performing integrity verification on a valve visual image; if the integrity verification passes, the valve visual image is determined as the inspection image; performing curve fitting on all image pixels based on the image coordinate system; removing non-compliant image pixels based on the image curve; generating a detection code for the valve to be inspected based on the target image pixels of the target inspection image; when a suspected verification code is generated, determining a first detection score based on the number of region divisions, and determining a second detection score based on an association rule algorithm and the number of region divisions; determining a comprehensive detection score for the valve to be inspected based on the first and second detection scores; and determining whether the valve to be inspected has surface defects based on the comprehensive detection score. This invention ensures the reliability of valve surface defect detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of valve inspection technology, and more specifically, to a method and system for detecting valve surface defects based on machine vision. Background Technology

[0002] As fluid control elements for flow control, valves are widely used in many industrial fields such as petrochemicals, shipbuilding, metallurgy and mining. During use, valves are affected by factors such as media, alternating stress, and mechanical wear, which can cause defects such as corrosion, fatigue cracking, and surface peeling on the valve surface.

[0003] Existing patent CN118154613B discloses a method and system for detecting surface defects of low-temperature valves based on machine vision. It directly acquires images of the valve surface and performs preprocessing such as denoising, enhancement, and binarization, without verifying the valve images. This can lead to detection failure due to issues such as incomplete images, incomplete captures, and blurring or distortion. Furthermore, it directly traverses image pixels for edge segmentation and grayscale analysis without filtering out noise points and interfering pixels that affect the detection results, making it impossible to accurately identify minor defects and resulting in insufficient defect recognition accuracy.

[0004] Therefore, it is necessary to design a machine vision-based method and system for detecting valve surface defects to solve the problems existing in the current technology. Summary of the Invention

[0005] In view of this, the present invention proposes a valve surface defect detection method and system based on machine vision, which aims to solve the problems of detection failure caused by incomplete images, incomplete shooting, blurring and distortion, and the influence of unfiltered noise points and interfering pixels on the detection results, which makes it impossible to accurately identify minor defects and results in insufficient defect recognition accuracy.

[0006] In one aspect, the present invention proposes a method for detecting surface defects in valves based on machine vision, comprising: The valve to be inspected is identified, a visual image of the valve to be inspected is acquired, and the integrity of the valve visual image is verified. If the integrity verification is passed, the valve visual image is determined as the inspection image. All image pixels of the detection image are obtained, an image coordinate system is constructed based on all image pixels, and curve fitting is performed on all image pixels based on the image coordinate system to determine the image curve of the valve to be detected. Based on the image curve, image pixels that do not conform to the curve are removed to determine the target detection image of the valve to be detected. Based on the target image pixels of the target detection image, a detection code is generated for the valve to be detected. The detection code includes a pass verification code, a defect verification code, and a suspected verification code. When the suspected verification code is generated, the target detection image is divided into regions. A first detection score is determined based on the number of regions divided, and a second detection score is determined based on the association rule algorithm and the number of regions divided. The comprehensive inspection score of the valve to be inspected is determined based on the first inspection score and the second inspection score, and the presence of surface defects in the valve to be inspected is determined based on the comprehensive inspection score.

[0007] Furthermore, when performing integrity verification on the valve visual image, the process includes: pre-selecting an image dataset, dividing the image dataset into a training set and a test set, training a deep learning model based on the training set, testing the trained deep learning model based on the test set, and finally determining the valve visual image as the input and the integrity verification result as the output. If the integrity verification result is that the integrity verification fails, the valve visual image of the valve to be detected is re-acquired.

[0008] Furthermore, in determining the target detection image of the valve to be detected, the process includes: using the detection time of each image pixel as the X-axis coordinate value, using the image pixel value of each image pixel as the Y-axis coordinate value, converting all image pixels into image coordinate points based on the X-axis and Y-axis coordinate values, constructing an image coordinate system based on all image coordinate points, performing curve fitting on all image coordinate points in the image coordinate system based on a fitting algorithm to determine the image curve of the valve to be detected, and removing image coordinate points that have not been curve fitted, and determining the target detection image of the valve to be detected based on the removal result.

[0009] Furthermore, when generating a detection code for the valve to be detected, the process includes: acquiring a standard target detection image corresponding to the target detection image, extracting all target image pixels from the target detection image, extracting standard target image pixels corresponding to the target image pixels in the standard target detection image, and determining the target image pixel value of each target image pixel and the standard target image pixel value of the corresponding standard target image pixel.

[0010] Furthermore, when generating a detection code for the valve to be inspected, the method further includes: generating a qualified verification code for the valve to be inspected when all the pixel values ​​of the target image are equal to the pixel values ​​of the standard target image; generating a defect verification code for the valve to be inspected when none of the pixel values ​​of the target image are equal to the pixel values ​​of the standard target image; and generating a suspected verification code for the valve to be inspected when one or more pixel values ​​of the target image are not equal to the pixel values ​​of the standard target image.

[0011] Furthermore, in determining the first detection score, the process includes: dividing the target detection image into regions, identifying several suspected regions, deleting a suspected region if all target image pixel values ​​within the suspected region are equal to the standard target image pixel values, determining the target suspected regions based on the deletion results, counting the number of target image pixels in all target suspected regions and recording it as the number of detected pixels, classifying the target image pixels within the target suspected regions whose target image pixel values ​​are greater than or equal to the corresponding standard target image pixel values ​​into a first detection set, and classifying the target image pixels within the target suspected regions whose target image pixel values ​​are less than the corresponding standard target image pixel values ​​into a second detection set.

[0012] Furthermore, when determining the first detection score, the method further includes: counting the number of target image pixels in the first detection set and recording it as the first detection number; counting the number of target image pixels in the second detection set and recording it as the second detection number; obtaining a first ratio of the first detection number to the number of detected pixels; obtaining a second ratio of the second detection number to the number of detected pixels; and performing a weighted calculation on the first ratio and the second ratio to determine the first detection score.

[0013] Furthermore, in determining the second detection score, the process includes: constructing several candidate itemsets for all suspected target regions using the Eclat algorithm; determining frequent itemsets based on the support of the candidate itemsets; determining the association results for each suspected target region based on the frequent itemsets; counting the total number of suspected target regions and recording it as the number of regions; counting the number of association results and recording it as the number of associations; and determining the ratio of the number of associations to the number of regions as the second detection score.

[0014] Furthermore, in determining whether the valve to be tested has surface defects, the method includes: performing a weighted calculation on the first test score and the second test score to determine the comprehensive test score; when the comprehensive test score is greater than or equal to the comprehensive test score threshold, it is determined that the valve to be tested has surface defects; when the comprehensive test score is less than the comprehensive test score threshold, it is determined that the valve to be tested does not have surface defects.

[0015] Compared with existing technologies, the advantages of this invention are as follows: By performing integrity verification on the visual image of the valve, the failure of the detection benchmark caused by problems such as image incompleteness, incomplete shooting, and blurring distortion can be avoided from the source. Only the image that passes the verification is determined as the detection image, ensuring the integrity of the detection data and improving the stability and reliability of the detection. By acquiring all image pixels to construct an image coordinate system and completing curve fitting, effective pixels and interference pixels can be accurately distinguished based on the true contour of the valve, thereby eliminating abnormal pixels that do not conform to the image curve and eliminating the interference of noise points and non-valve area pixels on defect identification. This allows for the accurate identification of defects such as corrosion, fatigue cracking, and surface peeling, improving the accuracy of defect identification. At the same time, by generating detection codes with qualified verification codes, defect verification codes, and suspected verification codes, a fine distinction between defects and suspected defects is achieved, avoiding missed detections and false detections caused by a single judgment. For suspected verification codes, by dividing the target detection image into regions and determining the first and second detection scores, suspected defects can be quantitatively analyzed from the dimensions of local pixel features and regional correlation. This ensures the pertinence and reliability of defect judgment, comprehensively improves the accuracy and credibility of detection results, and thus meets the needs of industrial fields for accurate detection of valve defects.

[0016] On the other hand, this application also provides a machine vision-based valve surface defect detection system for applying the above-mentioned machine vision-based valve surface defect detection method, including: The image acquisition unit is configured to identify the valve to be detected, acquire a visual image of the valve to be detected, and perform an integrity check on the visual image of the valve. If the integrity check is passed, the visual image of the valve is determined as the detection image. The image fitting unit is configured to acquire all image pixels of the detection image, construct an image coordinate system based on all image pixels, perform curve fitting on all image pixels based on the image coordinate system to determine the image curve of the valve to be detected, and remove non-compliant image pixels based on the image curve to determine the target detection image of the valve to be detected. The defect scoring unit is configured to generate a detection code for the valve to be detected based on the target image pixels of the target detection image. The detection code includes a pass verification code, a defect verification code, and a suspected verification code. When the suspected verification code is generated, the target detection image is divided into regions. A first detection score is determined based on the number of regions divided, and a second detection score is determined based on the association rule algorithm and the number of regions divided. The defect determination unit is configured to determine a comprehensive inspection score of the valve to be inspected based on the first inspection score and the second inspection score, and to determine whether the valve to be inspected has surface defects based on the comprehensive inspection score.

[0017] It is understandable that the above-mentioned machine vision-based valve surface defect detection method and system have the same beneficial effects, and will not be elaborated further here. Attached Figure Description

[0018] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0019] Figure 1 A flowchart illustrating a valve surface defect detection method based on machine vision, provided as an embodiment of the present invention; Figure 2 This is a functional block diagram of a valve surface defect detection system based on machine vision, provided for an embodiment of the present invention. Detailed Implementation

[0020] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0021] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0022] See Figure 1 As shown in some embodiments of this application, a machine vision-based method for detecting surface defects in valves includes: S100: Determine the valve to be inspected, acquire the valve visual image of the valve to be inspected, and perform integrity verification on the valve visual image. If the integrity verification is passed, the valve visual image is determined as the inspection image. S200: Obtain all image pixels of the detection image, construct an image coordinate system based on all image pixels, and perform curve fitting on all image pixels based on the image coordinate system to determine the image curve of the valve to be detected. Based on the image curve, remove image pixels that do not conform to the curve to determine the target detection image of the valve to be detected. S300: Generate detection codes for valves to be detected based on the target image pixels of the target detection image. The detection codes include qualified verification codes, defect verification codes, and suspected verification codes. When a suspected verification code is generated, the target detection image is divided into regions. The first detection score is determined based on the number of regions divided, and the second detection score is determined based on the association rule algorithm and the number of regions divided. S400: Determine the comprehensive inspection score of the valve to be inspected based on the first inspection score and the second inspection score, and determine whether the valve to be inspected has surface defects based on the comprehensive inspection score.

[0023] Specifically, identifying the valve to be inspected, including its model, specifications, installation location, and inspection range, avoids problems such as misaligned image acquisition and inaccurate inspection range due to unclear inspection targets, ensuring the targeted nature of the inspection work. A visual image of the valve to be inspected is acquired. This visual image contains all the morphological and textural features of the valve surface. A completeness check is performed on the visual image to verify whether it fully covers the entire surface of the valve to be inspected, and whether the image is free from motion blur, focus blur, lens distortion, and geometric deformation that could cause valve contour distortion. If the visual image is incomplete, poorly captured, or blurry and distorted, all subsequent analyses based on that image will lack a true benchmark, leading to missed or false defects and failing to accurately reflect the true defect state of the valve surface. When the visual image passes the completeness check, it proves that it meets the complete and clear inspection requirements, and is thus identified as the inspection image, laying the data foundation for subsequent pixel analysis. The process involves acquiring all image pixels of the inspection image. Image pixels are the smallest unit of machine vision analysis, and all defect features on the valve surface are reflected in the numerical values, positions, and distribution differences of these pixels. After acquiring all image pixels, an image coordinate system is constructed based on this system. Each image pixel corresponds to a unique coordinate position within the system, thus enabling management of all image pixels. Curve fitting is then performed on all image pixels based on this coordinate system. According to the valve's geometric shape, an image curve is fitted to all image pixels according to the valve's contour, accurately distinguishing between valid pixels belonging to the valve body and noise points, background interference pixels, and pixels outside the detection area. Based on the image curve, image pixels that do not conform to the fitting pattern are removed. These removed pixels are noise points and interference pixels that deviate from the valve's true contour. The remaining pixels are the true pixels on the valve surface to be inspected, thus determining the target inspection image of the valve. This eliminates the interference of invalid pixels on defect identification, improving the accuracy and reliability of defect detection.

[0024] Understandably, a detection code is generated for the valve to be inspected based on the target image pixels in the target detection image. The detection codes are divided into three categories: qualified verification codes, defect verification codes, and suspected verification codes. The generation of the detection code determines the defect status of the valve surface, thus classifying the valve surface into three states: a qualified verification code corresponds to no defects on the valve surface; a defect verification code corresponds to the presence of defects on the valve surface, triggering an alarm; and a suspected verification code corresponds to the possible presence of minor defects on the valve surface, requiring further inspection and analysis. Generating detection codes allows for a more refined distinction of the valve surface state, thereby identifying minor defects or suspected defects. When the generated detection code is a suspected verification code, the target detection image is divided into regions. The target detection image is split into several independent regions according to pixel distribution and contour features to ensure the uniformity of each region. The preferred number of regions is 30, but the specific number can be adjusted according to the actual size of the valve. Since suspected defects only exist in localized areas, if a holistic analysis method is used, the features of abnormal pixels will be diluted by a large number of normal pixels, making it impossible to accurately determine the degree of defect. Region division can focus on the suspected areas. After region segmentation, a first detection score is determined based on the number of regions. This first score quantifies the degree of anomaly in each segmented region based on the numerical and distributional features of the target image pixels, directly reflecting the severity of pixel anomalies in local areas. Simultaneously, a second detection score is determined based on an association rule algorithm and the number of regions. The association rule algorithm analyzes the spatial relationships and pixel anomaly association features between the segmented regions, determining whether suspected defect areas exhibit contiguous, diffuse, or associated distributions. The second detection score quantifies the risk of defect spread and its distribution range from the spatial association dimension of the defect areas. These two scores characterize the state of suspected defects from the perspectives of pixel features and regional association features, ensuring the reliability of defect detection. Based on the first and second detection scores, a comprehensive detection score is determined for the valve under inspection. This comprehensive detection score objectively, comprehensively, and accurately reflects the defect status of the valve surface. Using this quantified comprehensive detection score as a standard, refined defect detection of the valve surface is achieved, identifying various defects such as corrosion, fatigue cracking, and surface peeling, and improving the ability to identify minor defects, thus meeting the accuracy requirements for valve defect detection.

[0025] In some embodiments of this application, when performing integrity verification on a valve visual image, the process includes: pre-selecting an image dataset, dividing the image dataset into a training set and a test set, training a deep learning model based on the training set, testing the trained deep learning model based on the test set, and finally determining the input as the valve visual image and the output as the integrity verification result. If the integrity verification result is that the integrity verification fails, the valve visual image of the valve to be detected is re-acquired.

[0026] Specifically, the image dataset comprehensively covers visual images of valves in various states in industrial settings. It includes both clear, distortion-free images that fully cover the valve inspection surface and defective images with incomplete images, blurry focus, lighting distortion, and geometric distortion. This allows the model to fully learn various features of complete and incomplete valve visual images, avoiding model failure due to insufficient samples and ensuring the model's generalization ability to adapt to different image problems. The image dataset is divided into training and testing sets, typically in a 4:1 ratio, to ensure the model's generalization ability. The training set is used for feature learning, and the testing set is used to verify the model's performance. Deep learning models include Convolutional Neural Networks (CNNs) and Recurrent Neural Networks (RNNs). The training process involves the deep learning model autonomously extracting integrity features from valve visual images. During training, the model continuously learns image features and optimizes its network parameters and discrimination logic. After training and testing, the deep learning model can output integrity verification results based on the input valve visual image. The result of the integrity verification includes passing or failing the integrity verification. If the integrity verification fails, it means that there are problems such as incompleteness, incomplete shooting, blurring and distortion in the valve visual image. In this case, it is necessary to reacquire the valve visual image to be inspected, so as to ensure the image integrity of the inspection process from the source and lay the data foundation for subsequent pixel analysis and defect judgment.

[0027] It should be noted that the deep learning model in this application can preferably be implemented using existing technologies in the field, and it is not the focus of the improvement claimed in this application. The focus of the improvement in this application lies in its constraint processing logic for the valve visual image. The deep learning model takes the valve visual image as input and outputs the result of integrity verification. Those skilled in the art can complete the adaptation, replacement, or equivalent implementation based on the input-output relationship disclosed in this application, combined with existing disclosed technologies or conventional engineering methods, without affecting the implementation of the technical solution of this application.

[0028] In some embodiments of this application, determining the target detection image of the valve to be detected includes: using the detection time of each image pixel as the X-axis coordinate value, using the image pixel value of each image pixel as the Y-axis coordinate value, converting all image pixels into image coordinate points based on the X-axis and Y-axis coordinate values, constructing an image coordinate system based on all image coordinate points, performing curve fitting on all image coordinate points in the image coordinate system based on a fitting algorithm to determine the image curve of the valve to be detected, and removing image coordinate points that have not been curve fitted, and determining the target detection image of the valve to be detected based on the removal result.

[0029] Specifically, the detection time of each image pixel is used as the X-axis coordinate value. The detection time is the time it takes for each image pixel to be extracted from the visual image of the valve, with one image pixel extracted every few seconds. The image pixel value of each image pixel is used as the Y-axis coordinate value. The image pixel value represents the grayscale and other features of the image pixel, which corresponds to the physical state of the valve surface. Based on the X-axis and Y-axis coordinate values, each image pixel is converted into an image coordinate point containing time and pixel features. An image coordinate system is constructed based on the distribution of all image coordinate points. The image coordinate system is a Cartesian coordinate system (XY-axis coordinate system). Curve fitting is performed on all image coordinate points in the image coordinate system based on a fitting algorithm. The fitting algorithm includes least squares method, polynomial fitting algorithm, cubic spline fitting algorithm, etc., and any one of them can be selected. After the fitting is completed, image coordinate points that were not fitted to the curve are removed. These unfitted image coordinate points are image noise or interference factors in the pixel extraction process, and are therefore removed from the valve visual image. The target detection image of the valve to be detected is determined based on all image coordinate points on the image curve, thus eliminating the interference of invalid pixels on defect identification and improving the accuracy and reliability of defect detection.

[0030] In some embodiments of this application, when generating a detection code for the valve to be detected, the process includes: acquiring a standard target detection image corresponding to the target detection image, extracting all target image pixels from the target detection image, extracting standard target image pixels corresponding to the target image pixels from the standard target detection image, and determining the target image pixel value of each target image pixel and the standard target image pixel value of the corresponding standard target image pixel.

[0031] In some embodiments of this application, when generating a detection code for the valve to be inspected, the following steps are also included: when all the pixel values ​​of the target image are equal to the pixel values ​​of the standard target image, a qualified verification code is generated for the valve to be inspected; when none of the pixel values ​​of the target image are equal to the pixel values ​​of the standard target image, a defect verification code is generated for the valve to be inspected; and when one or more pixel values ​​of the target image are not equal to the pixel values ​​of the standard target image, a suspected verification code is generated for the valve to be inspected.

[0032] Specifically, the process involves acquiring a standard target inspection image corresponding to the target inspection image. This standard image is a standard image of a qualified valve free from defects such as corrosion, fatigue cracking, and surface peeling. It maintains a complete correspondence with the target inspection image in terms of model, specifications, shooting angle, and size ratio, avoiding pixel misalignment and comparison failures caused by mismatch between the reference and inspection images. After acquiring the corresponding standard target inspection image, all target image pixels are extracted from the target inspection image. Simultaneously, the corresponding standard target image pixels in the standard target inspection image are extracted. There is a one-to-one correspondence between target image pixels and standard target image pixels, and their pixel values ​​also correspond one-to-one. Defects on the valve surface such as corrosion, fatigue cracking, and surface peeling will cause changes in the pixel values ​​at corresponding locations. Converting pixel features into pixel values ​​and comparing them avoids subjective errors from manual judgment, achieving objective identification of defect features. When all pixel values ​​of the target image are equal to those of the standard target image, it indicates that the pixel features of all positions on the surface of the valve to be inspected are completely consistent with those of a standard qualified valve, and there are no defective features. In this case, a qualified verification code is generated for the valve to be inspected, and the surface of the valve to be inspected is determined to be qualified. When none of the pixel values ​​of the target image are equal to those of the standard target image, it indicates that the overall pixel features of the surface of the valve to be inspected deviate from those of a standard qualified valve, and there are large-area and obvious surface defects. In this case, a defect verification code is generated for the valve to be inspected, and the defect is directly determined. When one or more pixel values ​​of the target image are not equal to those of the standard target image, it indicates that there are local pixel anomalies on the surface of the valve to be inspected, which may be a minor defect or a suspected defect. In this case, a suspected defect verification code is generated for the valve to be inspected. By generating detection codes, a full-coverage and refined judgment of the surface state of the valve to be inspected is achieved, meeting the accuracy requirements for valve defect detection.

[0033] In some embodiments of this application, determining the first detection score includes: dividing the target detection image into regions, identifying several suspected regions, deleting the suspected region when the target image pixel values ​​in the suspected region are all equal to the standard target image pixel values, determining the target suspected region based on the deletion result, counting the number of target image pixels in all target suspected regions and recording it as the number of detected pixels, classifying the target image pixels in the target suspected region whose target image pixel values ​​are greater than or equal to the corresponding standard target image pixel values ​​into a first detection set, and classifying the target image pixels in the target suspected region whose target image pixel values ​​are less than the corresponding standard target image pixel values ​​into a second detection set.

[0034] In some embodiments of this application, when determining the detection first score, the method further includes: counting the number of target image pixels in the first detection set and recording it as the first detection number; counting the number of target image pixels in the second detection set and recording it as the second detection number; obtaining a first ratio of the first detection number to the number of detected pixels; obtaining a second ratio of the second detection number to the number of detected pixels; and performing a weighted calculation on the first ratio and the second ratio to determine the detection first score.

[0035] Specifically, the target detection image is divided into regions, and several suspected regions are identified. If all pixel values ​​in a suspected region are equal to the pixel values ​​in the standard target image, that suspected region is deleted. This process isolates localized areas with pixel anomalies in the target detection image, avoiding the dilution of abnormal features by a large number of normal pixels in the overall image. This allows the analysis to focus on the localized area where the suspected defect is located. The number of target image pixels in all suspected regions is counted and recorded as the number of detected pixels. The number of detected pixels is the total base number of all potentially abnormal pixels within the suspected region. Target image pixel values ​​in the suspected region that are greater than or equal to the corresponding standard target image pixel values ​​are considered as follows: The target image pixels are divided into a first detection set, and the target image pixels with pixel values ​​less than the corresponding standard target image pixel values ​​within the suspected target area are divided into a second detection set. Since different types of defects on the valve surface (such as surface peeling, corrosion, protrusions, and depressions) can cause abnormal changes in pixel values, separate classification can accurately distinguish the distribution of pixels with different abnormal characteristics. The ratio of the first detection quantity to the first number of detected pixels, and the ratio of the second detection quantity to the second number of detected pixels, convert the quantity into a relative proportion, which can intuitively reflect the distribution proportion of abnormal pixels within the suspected target area, further weakening the influence of area area on the determination of the degree of abnormality. A weighted calculation is performed on the first and second quantity ratios. The weighting calculation can allocate weights according to the degree of different pixel anomalies in the detection, and the weights of each quantity ratio can be determined using the analytic hierarchy process and expert scoring. The first detection score can intuitively and accurately reflect the overall degree of pixel anomalies within the suspected target area, thereby improving the accuracy and reliability of defect detection.

[0036] In some embodiments of this application, determining the second detection score includes: constructing several candidate itemsets for all suspected target regions according to the Eclat algorithm, determining frequent itemsets based on the support of the candidate itemsets, determining the association results of each suspected target region based on the frequent itemsets, counting the total number of all suspected target regions and recording it as the number of regions, counting the number of association results and recording it as the number of associations, and determining the ratio of the number of associations to the number of regions as the second detection score.

[0037] Specifically, based on the Eclat algorithm, several candidate item sets are constructed for all suspected target regions to adapt to the combinatorial association analysis of suspected target regions. The candidate item sets are formed by arranging all possible combinations of all suspected target regions, creating a candidate set covering all association possibilities. Frequent itemsets are determined based on the support of the candidate item sets. Support is an indicator that measures the frequency of occurrence of candidate item sets in all suspected target regions and the effectiveness of associations. Support filtering eliminates invalid candidate item sets that are random combinations, retaining only frequent itemsets that meet the support criteria and represent associations. This ensures that the obtained association results are all real and effective defect associations between suspected target regions. Based on the frequent itemsets, the association results of each suspected target region are determined, that is, from the filtered frequent itemsets, which suspected target regions have defect feature associations and spatial distribution associations, to clarify whether the defects exist in isolation. The detection method accurately depicts the overall distribution pattern of suspected defects on the valve surface by identifying contiguous diffusion and multi-regional collaborative anomalies. It counts the total number of suspected target areas as the number of areas, which serves as the base for correlation analysis. The number of correlation results is also counted as the number of correlations. The ratio of the number of correlations to the number of areas is determined as the second detection score. This ratio calculation transforms the absolute number of correlations into a relative correlation percentage, intuitively reflecting the overall correlation tightness of all suspected target areas. A higher ratio indicates stronger contiguousness of defect areas and a higher risk of diffusion, while a lower ratio indicates more isolated defect areas and lower risk. The second detection score fully presents the spatial correlation characteristics of defects, complementing the first detection score in terms of dimensions. It comprehensively assesses the status of suspected defects from two dimensions: pixel anomaly degree and regional correlation risk, further improving the accuracy and comprehensiveness of valve surface defect detection.

[0038] In some embodiments of this application, determining whether a valve to be tested has surface defects includes: performing a weighted calculation on a first detection score and a second detection score to determine a comprehensive detection score; when the comprehensive detection score is greater than or equal to a comprehensive detection score threshold, it is determined that the valve to be tested has surface defects; when the comprehensive detection score is less than the comprehensive detection score threshold, it is determined that the valve to be tested does not have surface defects.

[0039] Specifically, the first detection score and the second detection score are weighted and calculated. The first detection score reflects the degree of abnormality and distribution characteristics of the target image pixels in the suspected target area, while the second detection score reflects the spatial correlation between all suspected target areas and the risk of defect spread. The two scores characterize the suspected defect status from two dimensions: local pixel anomaly and global regional correlation, respectively. Their respective weights can also be determined by the analytic hierarchy process and expert scoring. This approach avoids emphasizing local pixel anomalies while ignoring the overall risk of defect spread, and also avoids focusing solely on regional correlation while weakening the characteristics of pixel anomalies. Through weighted fusion, the quantitative scores of the two independent dimensions can be integrated into a comprehensive index that fully reflects the true state of the defects on the surface of the valve to be inspected. When the overall detection score is greater than or equal to the overall detection score threshold, it indicates that the pixel anomaly level in the suspected target area of ​​the valve under test has exceeded the standard, and the risk of associated diffusion of the defect area has reached a hazardous level. Surface defects will affect the valve's performance and safety. Therefore, it is determined that the valve under test has surface defects. When the overall detection score is less than the overall detection score threshold, it indicates that even if the valve under test has local pixel anomalies, its anomaly level is low, and the defect area has no associated diffusion, failing to reach the critical standard for defects. Therefore, it is determined that the valve under test does not have surface defects, thereby reducing resource waste in industrial production and improving the accuracy and reliability of valve surface defect detection.

[0040] In summary, the beneficial effects of this invention are as follows: By performing integrity verification on the visual image of the valve, the failure of the detection benchmark caused by problems such as image incompleteness, incomplete shooting, and blurring distortion can be avoided from the source. Only images that pass the verification are determined as detection images, ensuring the integrity of the detection data and improving the stability and reliability of the detection. By acquiring all image pixels to construct an image coordinate system and completing curve fitting, effective pixels and interference pixels can be accurately distinguished based on the true contour of the valve, thereby eliminating abnormal pixels that do not conform to the image curve and eliminating the interference of noise points and non-valve area pixels on defect identification. This allows for the accurate identification of defects such as corrosion, fatigue cracking, and surface peeling, improving the accuracy of defect identification. At the same time, by generating detection codes with qualified verification codes, defect verification codes, and suspected verification codes, a refined distinction between defects and suspected defects is achieved, avoiding missed detections and false detections caused by a single judgment. For suspected verification codes, by dividing the target detection image into regions and determining the first and second detection scores, suspected defects can be quantitatively analyzed from the dimensions of local pixel features and regional correlation. This ensures the pertinence and reliability of defect judgment, comprehensively improves the accuracy and credibility of detection results, and thus meets the needs of industrial fields for accurate detection of valve defects.

[0041] In another preferred embodiment based on the above embodiments, see [reference] Figure 2As shown, this embodiment provides a valve surface defect detection system based on machine vision, used to apply a valve surface defect detection method based on machine vision, including: The image acquisition unit is configured to identify the valve to be inspected, acquire a visual image of the valve to be inspected, and perform an integrity check on the visual image of the valve. If the integrity check is passed, the visual image of the valve is determined as the inspection image. The image fitting unit is configured to acquire all image pixels of the detection image, construct an image coordinate system based on all image pixels, perform curve fitting on all image pixels based on the image coordinate system to determine the image curve of the valve to be detected, and remove image pixels that do not conform to the image curve to determine the target detection image of the valve to be detected. The defect scoring unit is configured to generate a detection code for the valve to be detected based on the target image pixels of the target detection image. The detection code includes a pass verification code, a defect verification code, and a suspected verification code. When a suspected verification code is generated, the target detection image is divided into regions. The first detection score is determined based on the number of regions divided, and the second detection score is determined based on the association rule algorithm and the number of regions divided. The defect determination unit is configured to determine the comprehensive inspection score of the valve to be inspected based on the first inspection score and the second inspection score, and to determine whether the valve to be inspected has surface defects based on the comprehensive inspection score.

[0042] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program goods according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0043] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit it. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that modifications or equivalent substitutions can still be made to the specific implementation of the present invention. Any modifications or equivalent substitutions that do not depart from the spirit and scope of the present invention should be covered within the scope of protection of the claims of the present invention.

Claims

1. A method for detecting surface defects in valves based on machine vision, characterized in that, include: The valve to be inspected is identified, a visual image of the valve to be inspected is acquired, and the integrity of the valve visual image is verified. If the integrity verification is passed, the valve visual image is determined as the inspection image. All image pixels of the detection image are obtained, an image coordinate system is constructed based on all image pixels, and curve fitting is performed on all image pixels based on the image coordinate system to determine the image curve of the valve to be detected. Based on the image curve, image pixels that do not conform to the curve are removed to determine the target detection image of the valve to be detected. Based on the target image pixels of the target detection image, a detection code is generated for the valve to be detected. The detection code includes a pass verification code, a defect verification code, and a suspected verification code. When the suspected verification code is generated, the target detection image is divided into regions. A first detection score is determined based on the number of regions divided, and a second detection score is determined based on the association rule algorithm and the number of regions divided. The comprehensive inspection score of the valve to be inspected is determined based on the first inspection score and the second inspection score, and the presence of surface defects in the valve to be inspected is determined based on the comprehensive inspection score.

2. The valve surface defect detection method based on machine vision according to claim 1, characterized in that, The process of performing integrity verification on the valve visual image includes: pre-selecting an image dataset, dividing the image dataset into a training set and a test set, training a deep learning model based on the training set, testing the trained deep learning model based on the test set, and finally determining the valve visual image as the input and the integrity verification result as the output. If the integrity verification result is that the integrity verification fails, the valve visual image of the valve to be detected is re-acquired.

3. The valve surface defect detection method based on machine vision according to claim 2, characterized in that, Determining the target detection image of the valve to be detected includes: using the detection time of each image pixel as the X-axis coordinate value, using the image pixel value of each image pixel as the Y-axis coordinate value, converting all image pixels into image coordinate points based on the X-axis and Y-axis coordinate values, constructing an image coordinate system based on all image coordinate points, performing curve fitting on all image coordinate points in the image coordinate system based on a fitting algorithm, determining the image curve of the valve to be detected, and removing image coordinate points that have not been curve fitted, and determining the target detection image of the valve to be detected based on the removal result.

4. The valve surface defect detection method based on machine vision according to claim 3, characterized in that, When generating a detection code for the valve to be detected, the process includes: acquiring a standard target detection image corresponding to the target detection image, extracting all target image pixels from the target detection image, extracting standard target image pixels corresponding to the target image pixels in the standard target detection image, and determining the target image pixel value of each target image pixel and the standard target image pixel value of the corresponding standard target image pixel.

5. The valve surface defect detection method based on machine vision according to claim 4, characterized in that, When generating a detection code for the valve to be inspected, the method further includes: generating a qualified verification code for the valve to be inspected when all the pixel values ​​of the target image are equal to the pixel values ​​of the standard target image; generating a defect verification code for the valve to be inspected when none of the pixel values ​​of the target image are equal to the pixel values ​​of the standard target image; and generating a suspected verification code for the valve to be inspected when one or more pixel values ​​of the target image are not equal to the pixel values ​​of the standard target image.

6. The valve surface defect detection method based on machine vision according to claim 5, characterized in that, When determining the first detection score, the process includes: dividing the target detection image into regions, identifying several suspected regions, deleting the suspected region if the target image pixel values ​​in the suspected region are all equal to the standard target image pixel values, determining the target suspected regions based on the deletion results, counting the number of target image pixels in all target suspected regions and recording it as the number of detected pixels, classifying the target image pixels in the target suspected regions whose target image pixel values ​​are greater than or equal to the corresponding standard target image pixel values ​​into a first detection set, and classifying the target image pixels in the target suspected regions whose target image pixel values ​​are less than the corresponding standard target image pixel values ​​into a second detection set.

7. The valve surface defect detection method based on machine vision according to claim 6, characterized in that, When determining the first detection score, the method further includes: counting the number of target image pixels in the first detection set and recording it as the first detection number; counting the number of target image pixels in the second detection set and recording it as the second detection number; obtaining a first ratio of the first detection number to the number of detected pixels; obtaining a second ratio of the second detection number to the number of detected pixels; and performing a weighted calculation on the first ratio and the second ratio to determine the first detection score.

8. The valve surface defect detection method based on machine vision according to claim 7, characterized in that, The process of determining the second detection score includes: constructing several candidate item sets for all suspected target regions using the Eclat algorithm; determining frequent itemsets based on the support of the candidate item sets; determining the association results of each suspected target region based on the frequent itemsets; counting the total number of suspected target regions and recording it as the number of regions; counting the number of association results and recording it as the number of associations; and determining the ratio of the number of associations to the number of regions as the second detection score.

9. The valve surface defect detection method based on machine vision according to claim 8, characterized in that, When determining whether the valve to be tested has surface defects, the method includes: performing a weighted calculation on the first test score and the second test score to determine the comprehensive test score; when the comprehensive test score is greater than or equal to the comprehensive test score threshold, it is determined that the valve to be tested has surface defects; when the comprehensive test score is less than the comprehensive test score threshold, it is determined that the valve to be tested does not have surface defects.

10. A machine vision-based valve surface defect detection system, used to apply the machine vision-based valve surface defect detection method as described in any one of claims 1-9, characterized in that, include: The image acquisition unit is configured to identify the valve to be detected, acquire a visual image of the valve to be detected, and perform an integrity check on the visual image of the valve. If the integrity check is passed, the visual image of the valve is determined as the detection image. The image fitting unit is configured to acquire all image pixels of the detection image, construct an image coordinate system based on all image pixels, perform curve fitting on all image pixels based on the image coordinate system to determine the image curve of the valve to be detected, and remove non-compliant image pixels based on the image curve to determine the target detection image of the valve to be detected. The defect scoring unit is configured to generate a detection code for the valve to be detected based on the target image pixels of the target detection image. The detection code includes a pass verification code, a defect verification code, and a suspected verification code. When the suspected verification code is generated, the target detection image is divided into regions. A first detection score is determined based on the number of regions divided, and a second detection score is determined based on the association rule algorithm and the number of regions divided. The defect determination unit is configured to determine a comprehensive inspection score of the valve to be inspected based on the first inspection score and the second inspection score, and to determine whether the valve to be inspected has surface defects based on the comprehensive inspection score.