A machine vision-based cable surface defect detection method and system
By adaptively adjusting the window size and contrast threshold, combined with similarity-weighted correction, the problem of uneven enhancement in cable surface detection by the traditional CLAHE algorithm is solved, achieving efficient and accurate defect detection.
Patent Information
- Application Number
- CN202511714876.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-21
- Publication Date
- 2026-02-24
- Estimated Expiration
- 2045-11-21
AI Technical Summary
The traditional CLAHE algorithm processes images using a fixed-size window, which cannot adapt to the complexity of different regions in cable surface images. It uses a single or untargeted contrast limiting threshold, resulting in over- or under-enhanced areas, affecting the accuracy of cable surface defect detection.
By constructing a local complexity evaluation model, adaptively adjusting the window size and contrast limit threshold, and combining similarity weighted correction, a balance between differentiated processing and enhancement effect is achieved. Defect detection is performed using a deep learning-based convolutional neural network.
It improves the accuracy and reliability of cable surface defect detection, adapts to the processing needs of areas with different complexities, reduces noise interference, and improves image quality and detection efficiency.
Smart Images

Figure CN121169927B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image data processing technology, and in particular to a method and system for detecting surface defects in cables based on machine vision. Background Technology
[0002] Ensuring product quality is paramount in cable production. Traditional methods for detecting surface defects in cables, such as manual inspection, are not only inefficient but also susceptible to human error, failing to meet the high precision and efficiency requirements of modern large-scale production. With the development of automated inspection technology, machine vision-based inspection methods are gradually becoming mainstream.
[0003] However, the diversity of cable surface materials and the complexity of lighting conditions in the production environment often result in low contrast and high noise interference in the acquired surface images, making it difficult to accurately extract defect features. Therefore, image enhancement algorithms can be used to make defect features more prominent, thereby improving the accuracy and efficiency of subsequent cable surface defect detection.
[0004] Contrast-Limited Adaptive Histogram Equalization (CLAHE) is a commonly used image enhancement algorithm that can improve image contrast when processing cable images. However, traditional CLAHE algorithms process images using fixed-size windows, which cannot adapt to the complexity of different regions in the image. For complex texture regions, fixed-size blocks may lead to loss of detail, while in simple background regions, it will waste computational resources. At the same time, traditional CLAHE algorithms usually use a single or untargeted contrast limiting threshold, which cannot take into account the enhancement needs of different regions, resulting in over-enhancement or under-enhancement of some regions, reducing the accuracy of displaying defect features in the surface image, and thus affecting the accuracy of cable surface defect detection. Summary of the Invention
[0005] To address the problems of the traditional CLAHE algorithm, which uses a fixed-size window to process images and cannot adapt to the complexity of different regions in surface images, and whose use of a single or untargeted contrast limiting threshold cannot meet the enhancement needs of different regions, resulting in over- or under-enhancement of some regions and thus affecting the accuracy of cable surface defect detection, this invention provides a cable surface defect detection method and system based on machine vision.
[0006] In a first aspect, the present invention provides a method for detecting surface defects in cables based on machine vision, employing the following technical solution:
[0007] A method for detecting surface defects in cables based on machine vision includes: acquiring a surface image of the cable and converting the surface image into a grayscale image; designating any pixel in the grayscale image as a target pixel, and determining the local complexity of the target pixel based on its grayscale value, the grayscale values of its neighboring pixels, and the gradient magnitude; segmenting the pixels in the grayscale image according to the local complexity to obtain several regions, determining the region complexity based on the average local complexity of all pixels within the region, and dividing the region corresponding to the complexity according to a preset window size to obtain multiple windows for each region; and for the target window within the multiple windows of each region, determining the local complexity of the region based on the target window... The contrast limit threshold of the target window is determined by taking the mean of the local complexity of all pixels within the target window, the standard deviation of the grayscale values of all pixels within the target window, the total number of grayscale levels in the grayscale image, and the size of the target window. Based on the contrast limit threshold, the CLAHE algorithm is used to process each window to obtain the enhanced grayscale values of the pixels within each window. For overlapping pixels between windows, the similarity between the overlapping pixels and their respective windows is obtained. The enhanced grayscale values of the overlapping pixels are then corrected based on the similarity to obtain the corrected enhanced grayscale values of the overlapping pixels, thus obtaining the enhanced grayscale image. Finally, a defect detection algorithm is used to detect surface defects on the cable using the enhanced grayscale image.
[0008] This invention constructs a local complexity evaluation model by analyzing the gray values of target pixels and the gray values and gradient magnitudes of pixels in their neighborhood. This model accurately reflects the texture complexity of different regions in an image, providing a reliable regional feature basis for subsequent adaptive image segmentation and parameter adjustment. Through image segmentation based on local complexity, differentiated processing of regions with different complexities is achieved. The window size is adaptively determined based on the mean of regional complexity, ensuring that different complexity regions receive more suitable processing parameters, overcoming the limitation of the fixed window size in the traditional CLAHE algorithm. By constructing a composite function including the mean of local complexity, gray standard deviation, total number of gray levels, and window size, adaptive evaluation of the contrast limit threshold is achieved. This function can dynamically adjust according to the image features within the window, effectively balancing the contradiction between enhancement effect and noise suppression. Through similarity analysis of overlapping pixels in the window and correction of enhanced gray values, discontinuities at the window boundaries are effectively eliminated, improving the smoothness and consistency of the enhanced image, enhancing the accuracy and reliability of cable surface defect detection, and providing a high-quality image foundation for machine vision inspection systems.
[0009] Furthermore, the gradient magnitude is obtained using the Sobel operator.
[0010] Furthermore, the local complexity satisfies: In the formula, For pixels Local complexity, For pixels The number of other pixels in the neighborhood. For pixels grayscale value, For pixels Within the neighborhood of The grayscale value of each pixel For pixels Within the neighborhood of The gradient magnitude of each pixel.
[0011] This invention constructs a local complexity evaluation index by calculating the average value of the grayscale difference and gradient magnitude between the target pixel and its neighboring pixels. By comprehensively considering grayscale changes and gradient information, it can more accurately reflect the texture complexity of local areas. The grayscale difference term reflects the contrast characteristics of local areas, while the gradient magnitude term reflects the intensity of edges and textures. The combination of the grayscale difference term and the gradient magnitude term ensures that the complexity calculation considers both grayscale changes and structural features, and can sensitively capture the texture feature differences of different areas on the cable surface, providing reliable regional feature input for subsequent adaptive image processing.
[0012] Furthermore, the image segmentation employs a region growing algorithm.
[0013] Furthermore, the step of determining the region complexity based on the average local complexity of all pixels within the region includes: determining the region as a high-complexity region in response to the average value being greater than a high-complexity threshold; determining the region as a medium-complexity region in response to the average value being neither greater than the high-complexity threshold nor less than a low-complexity threshold; and determining the region as a low-complexity region in response to the average value being less than a low-complexity threshold.
[0014] Furthermore, the contrast limiting threshold satisfies: In the formula, For the first Contrast limit threshold for each window These are the preset global contrast limit control parameters. The local complexity influence factor is preset. For the first The average local complexity of all pixels within a window. For the first The standard deviation of the grayscale values of all pixels within a window This represents the total number of gray levels in the grayscale image. For the first The width of each window, For the first The height of each window This is the standard normalization function.
[0015] This invention achieves adaptive calculation of the contrast limit threshold by constructing a composite function that includes the mean of local complexity and the standard deviation of grayscale. It comprehensively considers the texture complexity and grayscale distribution characteristics within the window, ensuring that the threshold can adapt to the image characteristics of different regions. The introduction of the mean of local complexity allows complex texture regions to obtain a higher contrast limit threshold, avoiding over-enhancement. The standard deviation of grayscale reflects the contrast level within the window; regions with a large standard deviation require stronger contrast limitation. The normalization factor eliminates the influence of different window sizes and grayscale levels, ensuring a reasonable range for the threshold. This allows for dynamic adjustment of the limitation intensity based on window characteristics, effectively balancing enhancement effects and noise suppression, and improving the applicability of the CLAHE algorithm in cable surface defect detection.
[0016] Furthermore, the similarity satisfies: In the formula, For the first Overlapping pixels and their respective windows similarity, For the first Local complexity of overlapping pixels, For the first The window to which the overlapping pixels belong The mean of the local complexity of all pixels within the range. For the first The grayscale values of overlapping pixels For the first The window to which the overlapping pixels belong The average grayscale value of all pixels within the range. For the first The window to which the overlapping pixels belong The standard deviation of the grayscale values of all pixels within the range It is the absolute value symbol.
[0017] This invention constructs a composite function that includes local complexity difference and grayscale difference to evaluate the similarity between overlapping pixels and their respective windows. It comprehensively considers the matching degree of texture features and grayscale features to ensure the comprehensiveness and accuracy of similarity evaluation. The local complexity difference term reflects the matching degree of overlapping pixels and windows in terms of texture complexity, while the grayscale difference term reflects the matching degree of grayscale features and has been standardized.
[0018] Furthermore, the modified enhanced grayscale value satisfies: In the formula, For the first Enhance grayscale values after correcting overlapping pixels For the first The number of windows to which each overlapping pixel belongs. For the first Overlapping pixels and their respective windows similarity, For the first The sum of the similarity between each overlapping pixel and its corresponding window. For the first Overlapping pixels in their respective windows Enhanced grayscale values within.
[0019] This invention achieves intelligent correction of grayscale values for overlapping pixels by constructing a similarity-based weighted average model. Weighted fusion is performed based on the similarity between overlapping pixels and their respective windows, ensuring that the corrected grayscale values better reflect the actual characteristics of the pixels. The similarity normalization weights ensure that the sum of all weights is 1, avoiding bias in weight allocation and allowing similarity values with high feature matching to contribute more significantly, resulting in more accurate feature fusion. Through the weighted correction mechanism, the block artifact problem at the window boundaries of the traditional CLAHE algorithm is effectively solved, improving the overall quality and consistency of the enhanced image and providing a higher-quality image foundation for subsequent cable surface defect detection.
[0020] Furthermore, the defect detection algorithm employs a deep learning-based convolutional neural network algorithm.
[0021] Secondly, the present invention provides a cable surface defect detection system based on machine vision, which adopts the following technical solution:
[0022] A machine vision-based cable surface defect detection system includes a processor and a memory, wherein the memory stores computer program instructions, and when the computer program instructions are executed by the processor, the aforementioned machine vision-based cable surface defect detection method is implemented.
[0023] By adopting the above technical solution, a computer program for the above-mentioned cable surface defect detection method based on machine vision is generated and stored in a memory so that it can be loaded and executed by a processor. In this way, a terminal device can be made based on the memory and the processor for convenient use.
[0024] The present invention has the following technical effects:
[0025] (1) Breaking through the limitations of the traditional CLAHE fixed window processing of the whole image, the window size is matched differently by local complexity. First, the local complexity is calculated based on the gray value of the pixel, the gray value of the neighborhood and the gradient magnitude. For example, the local complexity of the defect area on the cable surface is high due to the many gray value changes, while the complexity of the smooth area is low. Then, the window is divided according to the complexity of the region. Small windows are used in high complexity areas, such as the area around scratches and depressions, so as to capture the subtle gray value changes of the defect edge. Large windows are used in low complexity areas, such as the smooth surface of the cable without defects, to avoid the enhancement fragmentation caused by over-segmentation. Thus, the problem of insufficient enhancement of complex areas and over-enhancement of simple areas caused by fixed windows in the traditional method is solved, and different areas are ensured to receive appropriate enhancement processing.
[0026] (2) Abandoning the traditional CLAHE single threshold strategy for managing the entire image, the contrast limit threshold is dynamically generated through multi-dimensional parameters. For example, the window where the fine scratches on the cable surface are located has medium complexity and small gray standard deviation, so the threshold will be appropriately reduced to enhance the gray difference between the scratches and the background. On the other hand, the noise-dense area has high complexity and large standard deviation, so the threshold will be appropriately increased to avoid the noise being excessively amplified. The adaptive adjustment not only ensures the clear enhancement of defect features, such as fine scratches and small depressions, but also prevents the noise in the non-defective area from being mistakenly enhanced, thus better balancing the defects and noise in the image.
[0027] (3) To address the issues of brightness jumps and splicing marks that are common in the overlapping areas of traditional CLAHE windows, visual tomography is eliminated by similarity weighting correction. The similarity between overlapping pixels and their respective windows is calculated, such as the matching degree of grayscale distribution and gradient direction. The enhanced grayscale values output by different windows are weighted and fused. The higher the similarity between a pixel and a certain window, the greater the weight of the window's enhancement value. For example, in the case of continuous scratches across windows on the surface of a cable, the overlapping pixels will preferentially inherit the enhancement features of the main scratch window, avoiding scratch breakage or brightness abrupt changes due to window switching. This ensures that the enhanced image is coherent and without obvious splicing marks, avoiding the problem of splicing marks being misjudged as minor defects in traditional CLAHE, and providing a more accurate image basis for subsequent defect detection.
[0028] (4) Fully consider the complexity and diversity of cable surfaces, such as the differences in surface texture of cables of different materials, slight stains that may be attached during the production process, and the changes in grayscale distribution under different lighting conditions. Through dynamic calculation of local complexity, it can adapt to different scenarios. For cable surfaces with dense textures, such as the anti-slip texture of rubber cables, the local complexity calculation can distinguish between normal textures and defect textures. Window and threshold adjustments can prevent normal textures from being over-enhanced. For areas with uneven lighting, such as local reflections of cables, the grayscale standard deviation is involved in the threshold calculation, which can balance the enhancement intensity of reflective and shadow areas and avoid local over-brightness or under-darkness. Compared with the traditional CLAHE, which is not adaptable to scene changes, it can be stably applied to the detection of cable surface defects under different types and working conditions, reducing the cost of manual parameter adjustment. Attached Figure Description
[0029] Figure 1 This is a flowchart of a cable surface defect detection method based on machine vision according to an embodiment of the present invention.
[0030] Figure 2 This is a schematic diagram of the overlapping portion of multiple windows in a certain area and the rest of the area in a cable surface defect detection method based on machine vision according to an embodiment of the present invention. The white area is a certain area after image segmentation, and the gray area is the overlapping portion of multiple windows in that area and the rest of the area. Detailed Implementation
[0031] The purpose of this invention is to provide a method and system for detecting cable surface defects based on machine vision. This method can dynamically divide the image into blocks according to the local features of different regions, achieve adaptive window size adjustment, effectively enhance image contrast, and improve image quality to meet the needs of cable image detection.
[0032] 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, not all, of the embodiments of the present invention. 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.
[0033] This invention discloses a method for detecting surface defects in cables based on machine vision, referring to... Figure 1 This includes steps S001-S006:
[0034] S001: Acquire a surface image of the cable and convert the surface image into a grayscale image.
[0035] It's important to note that using a high-resolution industrial camera, with an appropriate frame rate and resolution selected based on the cable's dimensions, ensures clear capture of cable surface details. A suitable lighting system, such as a ring light or backlight, is also crucial to provide uniform and stable illumination, minimizing the impact of shadows and reflections on image quality. The camera's installation position and shooting angle are determined based on the cable's shape and manufacturing process to obtain the best image of the cable surface. For example, for round cables, the camera can be mounted directly above, shooting vertically onto the cable surface; for flat cables, an appropriate tilt angle can be selected based on its width and thickness to fully showcase the cable's surface features. The acquired color surface images are then converted to grayscale images to reduce data volume, improve processing speed, and eliminate interference from color information in subsequent processing.
[0036] S002: Determine the local complexity of each pixel.
[0037] It should be noted that in cable surface defect detection, high-quality cable surfaces have relatively uniform texture and grayscale distribution. Once defects such as scratches, dents, protrusions, or impurities appear on the cable surface, these defective areas will exhibit significant feature differences at the pixel level compared to the surrounding normal areas. From the perspective of grayscale difference, the pixel grayscale values in normal cable surface areas change little, resulting in low grayscale difference; while in defective areas, such as scratches, the pixel grayscale values may differ from the surrounding normal parts, leading to increased grayscale difference. This change in grayscale difference can preliminarily determine whether there is an anomaly on the cable surface. From the perspective of gradient information analysis, the texture of the cable surface and the edges of defects will cause changes in the gradient amplitude of pixels. On normal cable surfaces, the gradient amplitude of pixels is relatively stable, but at the edges of defects, the changes in pixels in the horizontal and vertical directions are amplified, and the gradient amplitude increases. Therefore, this step, by comprehensively considering the two key factors of grayscale difference and gradient amplitude, can comprehensively measure the local complexity of pixels in the cable image.
[0038] Any pixel in the grayscale image is designated as the target pixel. The local complexity of the target pixel is determined based on its grayscale value, as well as the grayscale values and gradient magnitudes of the other pixels in its neighborhood.
[0039] The implementer can adjust the neighborhood size of the target pixel according to the specific implementation situation, for example, an 8-neighborhood.
[0040] Specifically, the gradient magnitude is obtained using the Sobel operator.
[0041] Specifically, the local complexity satisfies:
[0042] ;
[0043] In the formula, For pixels Local complexity, For pixels The number of other pixels in the neighborhood. For pixels grayscale value, For pixels Within the neighborhood of The grayscale value of each pixel For pixels Within the neighborhood of The gradient magnitude of each pixel.
[0044] in, Represents pixels The complexity of the local region; the larger this value, the more complex the pixel. The more drastic the change in grayscale value within a neighborhood, or the higher the gradient amplitude, the more likely there is a defect on the cable surface in that area. For example, the pixel value at a scratch will be higher than in a normal area. When there is a defect on the cable surface, the pixel grayscale value in the defective area will differ from that in the surrounding normal area. This will increase the risk. If impurities adhere to the cable surface, the difference between the impurity pixels and the surrounding normal cable pixels will be significant, which will... The value increases, The larger the value, the greater the local complexity; at the texture and edge of defects on the cable surface, the gradient magnitude of pixels will change. For example, at the edge of scratches on the cable surface, the changes in pixels in the horizontal and vertical directions are intensified. The larger it is, therefore, The larger the value, the richer the edge and texture information of the region, the more likely it is to have defects or complex surface features, and the greater the local complexity.
[0045] S003: Obtain several regions of the grayscale image and determine their complexity, then divide each region to obtain multiple windows for each region.
[0046] It should be noted that different window sizes are used for processing different regions. For highly complex regions, smaller windows, such as 2×2, are used to accurately capture details, reduce computational redundancy, and enhance the targeting of processing. For medium-complex regions, relatively moderate windows, such as 4×4, are selected to balance detail preservation and computational efficiency. For low-complexity regions, larger windows, such as 6×6, are used to improve processing efficiency and reduce unnecessary computation.
[0047] Based on the local complexity, the pixels in the grayscale image are segmented to obtain several regions. The region complexity is determined based on the average local complexity of all pixels in the region. The regions with corresponding complexity are divided according to the preset window size to obtain multiple windows for each region.
[0048] Specifically, the image segmentation employs a region growing algorithm.
[0049] Specifically, determining the region complexity based on the average local complexity of all pixels within the region includes:
[0050] If the mean value is greater than the high complexity threshold, the region is identified as a high complexity region.
[0051] If the mean value is not greater than the high complexity threshold and not less than the low complexity threshold, the region is identified as a medium complexity region.
[0052] In response to the mean being less than the low complexity threshold, the region is identified as a low complexity region.
[0053] Implementers can set high complexity thresholds and low complexity thresholds according to the specific implementation situation. For example, the high complexity threshold is 0.8 and the low complexity threshold is 0.3.
[0054] S004: Determine the contrast limit threshold for each window.
[0055] It should be noted that by flexibly adjusting the contrast enhancement intensity based on the complexity and pixel distribution of different windows, the system ensures that image details are clearly displayed without excessive enhancement that could lead to noise amplification or image distortion. By integrating multiple factors related to local and global image properties, a suitable contrast limit threshold is dynamically generated for each window.
[0056] For a target window in multiple windows in each region, the contrast limit threshold of the target window is determined based on the mean of the local complexity of all pixels in the target window, the standard deviation of the gray values of all pixels in the target window, the total number of gray levels in the grayscale image, and the size of the target window.
[0057] Specifically, the contrast limiting threshold satisfies:
[0058] ;
[0059] In the formula, For the first Contrast limit threshold for each window These are the preset global contrast limit control parameters. The local complexity influence factor is preset. For the first The average local complexity of all pixels within a window. For the first The standard deviation of the grayscale values of all pixels within a window This represents the total number of gray levels in the grayscale image. For the first The width of each window, For the first The height of each window This is the standard normalization function.
[0060] Implementers can set control parameters and influence factors according to the specific implementation situation. For example, the control parameter is 1.5 and the influence factor is 0.3.
[0061] in, This reflects the complexity of the image content within the window. In a cable surface image, if the window is located on a smooth surface area of the cable, The value is relatively low if the window includes cable edges, damage, or attached impurities. The value will increase significantly. The value can adjust the contrast differently based on the complexity of different areas, allowing details in complex areas to be presented better, such as in areas of cable damage, where a higher contrast value will be more effective. This will lead to a greater enhancement of contrast in the area, making it easier to detect. The larger the value, the larger the contrast limit threshold. This reflects the dispersion of pixel grayscale values within the window, i.e., the contrast. A larger value indicates a greater difference in grayscale values among pixels within the window, resulting in higher contrast in the corresponding area. This may contain information such as the boundary between the cable and the background, or the transition between different materials on the cable surface. When... When the value is small, it means that the pixel gray values within the window are relatively close and the contrast is low. It may be a uniform area of the cable. When calculating the threshold, this can be taken into account so that areas with high contrast are more restricted when adjusting the contrast, preventing over-enhancement that could lead to loss of detail or amplification of noise. Areas with low contrast, on the other hand, have more room for adjustment to enhance their details. It reflects the overall grayscale distribution range and richness of the image. The more grayscale levels there are, the richer the grayscale variations the image can present, and the larger the range from the darkest to the brightest may be. and They are the first The width and height of the first window, their product represents the width and height of the second window. The size of a window reflects the number of pixels and spatial range covered by a local area, therefore, This comprehensively reflects the relationship between the grayscale features of the entire image and the size of a specific local window. This means that larger windows will receive relatively smaller values when calculating the contrast limit threshold, because larger windows may contain more details and information, requiring gentler contrast adjustments to prevent over-enhancement that could lead to loss of detail or amplification of noise. On the other hand, smaller windows correspond to relatively larger values, allowing for stronger contrast adjustments to the image within the smaller window to highlight the details present within it.
[0062] S005: Image enhancement is performed using the CLAHE algorithm to obtain an enhanced grayscale image.
[0063] It should be noted that because defects on the cable surface are not regularly distributed, the shapes of each region may also be irregular. Therefore, when dividing the regions into windows, such as... Figure 2 As shown, a window at the edge of a region may contain pixels from another region; these pixels are called overlapping pixels. Based on the contrast limit threshold, the CLAHE algorithm is used to enhance the image of each window. Overlapping pixels undergo multiple enhancements. Therefore, it is necessary to determine the weight of each window based on the similarity between the overlapping pixels and their respective windows. Then, the enhanced grayscale values of the overlapping pixels within each window are weighted and summed to obtain the corrected enhanced grayscale value of the overlapping pixels. The similarity between overlapping pixels and their respective windows can be determined by the difference in local complexity and grayscale value between the overlapping pixels and the pixels within the window. This is achieved by adding the difference in local complexity and the difference in grayscale value (normalized by standard deviation), adjusting the denominator by adding 1, and finally taking the reciprocal to obtain the similarity. The smaller the difference, the higher the similarity. That is, the closer the local complexity and grayscale value of the overlapping pixel are to the mean of the pixels within the window, the higher the similarity between the pixel and the window.
[0064] Based on the contrast limit threshold, the CLAHE algorithm is used to process each window to obtain the enhanced grayscale value of the pixels in each window. For overlapping pixels between windows, the similarity between the overlapping pixels and their respective windows is obtained.
[0065] Specifically, the similarity satisfies:
[0066] ;
[0067] In the formula, For the first Overlapping pixels and their respective windows similarity, For the first Local complexity of overlapping pixels, For the first The window to which the overlapping pixels belong The mean of the local complexity of all pixels within the range. For the first The grayscale values of overlapping pixels For the first The window to which the overlapping pixels belong The average grayscale value of all pixels within the range. For the first The window to which the overlapping pixels belong The standard deviation of the grayscale values of all pixels within the range It is the absolute value symbol.
[0068] The enhanced grayscale values of overlapping pixels are corrected based on the similarity to obtain the corrected enhanced grayscale values of the overlapping pixels, and thus the enhanced grayscale image is obtained.
[0069] Specifically, the modified enhanced grayscale value satisfies:
[0070] ;
[0071] In the formula, For the first Enhance grayscale values after correcting overlapping pixels For the first The number of windows to which each overlapping pixel belongs. For the first Overlapping pixels and their respective windows similarity, For the first The sum of the similarity between each overlapping pixel and its corresponding window. For the first Overlapping pixels in their respective windows Enhanced grayscale values within.
[0072] S006: The enhanced grayscale image is used to detect defects on the cable surface using a defect detection algorithm.
[0073] Specifically, the defect detection algorithm employs a deep learning-based convolutional neural network algorithm.
[0074] The detection process using a deep learning-based convolutional neural network algorithm is as follows: Multiple enhanced grayscale images of cable surfaces containing both normal and various defects are acquired and labeled. After preprocessing such as normalization, a convolutional neural network is constructed based on a classic architecture. Hyperparameters are set, pooling and activation functions are added, and the model is trained using loss functions such as cross-entropy and optimizers such as stochastic gradient descent. The model is evaluated and optimized using a validation set. Finally, the image to be detected is input into the trained model, and the output prediction results determine whether the cable has production quality problems, such as scratches, wear, cracks, bubbles, and impurities. An early warning is then issued, completing the machine vision-based cable surface defect detection.
[0075] This invention also discloses a cable surface defect detection system based on machine vision, including a processor and a memory. The memory stores computer program instructions, which, when executed by the processor, implement a cable surface defect detection method based on machine vision according to the present invention.
[0076] The system also includes other components well known to those skilled in the art, such as communication buses and communication interfaces, the settings and functions of which are known in the art and will not be described in detail here.
[0077] The above are all preferred embodiments of the present invention and are not intended to limit the scope of protection of the present invention. Therefore, all equivalent changes made in accordance with the structure, shape and principle of the present invention should be covered within the scope of protection of the present invention.
Claims
1. A method for detecting surface defects in cables based on machine vision, characterized in that, include: Acquire a surface image of the cable and convert the surface image to a grayscale image; Any pixel in the grayscale image is designated as the target pixel. The local complexity of the target pixel is determined based on its grayscale value, as well as the grayscale values and gradient magnitudes of the other pixels in its neighborhood. Local complexity satisfies: In the formula, For pixels Local complexity, For pixels The number of other pixels in the neighborhood. For pixels grayscale value, For pixels Within the neighborhood of The grayscale value of each pixel For pixels Within the neighborhood of Gradient magnitude of each pixel; Based on the local complexity, the pixels within the grayscale image are segmented to obtain several regions. The complexity of each region is determined based on the average local complexity of all pixels within that region, including: identifying a region as a high-complexity region if the average is greater than a high-complexity threshold; identifying a region as a medium-complexity region if the average is neither greater than a high-complexity threshold nor less than a low-complexity threshold; and identifying a region as a low-complexity region if the average is less than a low-complexity threshold. Furthermore, regions of corresponding complexity are divided according to a preset window size to obtain multiple windows for each region. For the target window in multiple windows in each region, the contrast limit threshold of the target window is determined based on the mean of the local complexity of all pixels in the target window, the standard deviation of the gray values of all pixels in the target window, the total number of gray levels in the grayscale image, and the size of the target window. Based on the contrast limit threshold, the CLAHE algorithm is used to process each window to obtain the enhanced grayscale value of the pixels in each window. For overlapping pixels between windows, the similarity between the overlapping pixels and their respective windows is obtained. The enhanced grayscale value of the overlapping pixels is corrected based on the similarity to obtain the corrected enhanced grayscale value of the overlapping pixels, and then the enhanced grayscale image after image enhancement is obtained. The enhanced grayscale image is used to detect defects on the cable surface using a defect detection algorithm.
2. The method for detecting cable surface defects based on machine vision according to claim 1, characterized in that, The gradient magnitude is obtained using the Sobel operator.
3. The method for detecting cable surface defects based on machine vision according to claim 1, characterized in that, The image segmentation uses a region growing algorithm.
4. The method for detecting cable surface defects based on machine vision according to claim 1, characterized in that, The contrast limiting threshold satisfies: ; In the formula, For the first Contrast limit threshold for each window These are the preset global contrast limit control parameters. The local complexity influence factor is preset. For the first The average local complexity of all pixels within a window. For the first The standard deviation of the grayscale values of all pixels within a window This represents the total number of gray levels in the grayscale image. For the first The width of each window, For the first The height of each window This is the standard normalization function.
5. The method for detecting cable surface defects based on machine vision according to claim 1, characterized in that, The similarity satisfies: ; In the formula, For the first The overlapping pixels and their respective windows similarity, For the first Local complexity of overlapping pixels, For the first The window to which the overlapping pixels belong The mean of the local complexity of all pixels within the range. For the first The grayscale values of overlapping pixels For the first The window to which the overlapping pixels belong The average grayscale value of all pixels within the range. For the first The window to which the overlapping pixels belong The standard deviation of the grayscale values of all pixels within the range It is the absolute value symbol.
6. The method for detecting cable surface defects based on machine vision according to claim 1, characterized in that, The corrected enhanced grayscale value satisfies: ; In the formula, For the first Enhance grayscale values after correcting overlapping pixels For the first The number of windows to which each overlapping pixel belongs. For the first The overlapping pixels and their respective windows similarity, For the first The sum of the similarity between each overlapping pixel and its corresponding window. For the first Overlapping pixels in their respective windows Enhanced grayscale values within.
7. The method for detecting cable surface defects based on machine vision according to claim 1, characterized in that, The defect detection algorithm employs a deep learning-based convolutional neural network algorithm.
8. A cable surface defect detection system based on machine vision, characterized in that, include: A processor and a memory, the memory storing computer program instructions that, when executed by the processor, implement a machine vision-based cable surface defect detection method according to any one of claims 1-7.
Citation Information
Patent Citations
Wire and cable defect detection method and system based on computer vision
CN114757949A
Cable surface defect detection method
CN115222741A