A cable surface sheath image preprocessing method, device, equipment and medium
By dividing the cable surface sheath image into regions and performing eight-neighbor connected domain analysis, the problems of uneven illumination and reflection interference caused by the curved surface characteristics of the cable are solved, achieving high-precision defect detection, reducing false alarm rate and false negative rate, and making it suitable for real-time detection in cable production lines.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHENGDU TECH UNIV
- Filing Date
- 2026-04-28
- Publication Date
- 2026-05-29
AI Technical Summary
The uneven illumination and reflection interference caused by the curved surface characteristics of the cable sheath during the production process result in high false alarm and false negative rates in existing detection methods, which cannot meet the detection accuracy requirements of modern production lines.
By dividing the cable surface sheath image into multiple regions, calculating the gray-scale mean and standard deviation of each region, determining the deviation range based on the 3σ criterion, judging the gray-scale deviation of pixels, constructing an eight-neighbor connected domain, and distinguishing noise and defect regions based on area thresholds for differentiated processing.
It reduces the false alarm rate and false negative rate of defect detection, and realizes high-precision automated detection of surface defects in cable sheaths, meeting the real-time detection needs of modern production lines.
Smart Images

Figure CN122115442A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, specifically to a method, apparatus, device, and medium for preprocessing images of cable surface sheaths. Background Technology
[0002] During cable manufacturing, a plastic sheath is wrapped around the cable surface to provide protection against corrosion, aging, mechanical damage, and water and moisture. Molten sheath material (such as PVC or PE) forms a uniform outer sheath layer around the cable core, which is then cooled, shaped, and wound up. However, during the extrusion of the sheath onto the cable surface, defects such as scratches, abrasions, tears, bulges, bubbles, and cracks can easily occur due to impurities in the sheath material, insufficient cooling, external pressure, or scratches. These defects not only damage the product's appearance but also cause serious problems in terms of protective performance, electrical safety, mechanical reliability, service life, and compliance, potentially leading to safety accidents and economic losses during subsequent installation and use.
[0003] Currently, the detection of defects in cable sheaths mainly relies on manual visual inspection and machine vision inspection. Manual visual inspection is extremely inefficient and cannot keep up with the production speed of modern production lines, which exceeds 200 meters per minute. Existing machine vision inspection methods typically use mean filtering, median filtering, and other filtering techniques to smooth the image globally or locally. However, because cable sheaths have a circular curved surface, they are prone to reflection when illuminated, and their surface texture is uneven, resulting in severe interference in the acquired image. Fixed filtering operators cannot simultaneously adapt to the different characteristics of bright and dark areas, leading to missed or false detections, and failing to meet the actual inspection accuracy requirements of enterprises. Summary of the Invention
[0004] The technical problem to be solved by the present invention is how to solve the problem of high false alarm rate and false negative rate in subsequent defect detection caused by uneven illumination and reflection interference due to the curved surface characteristics of cables. The purpose is to provide a method, device, equipment and medium for preprocessing images of cable surface sheaths, which solves the above problems.
[0005] This invention is achieved through the following technical solution:
[0006] In a first aspect, the present invention provides a method for preprocessing images of cable surface sheaths, comprising:
[0007] Acquire images of the cable surface sheath;
[0008] The image of the cable surface sheath is divided into multiple regions;
[0009] Calculate the mean gray value and standard deviation σ of all pixels in each region, and determine the deviation range based on the 3σ criterion;
[0010] Calculate the grayscale deviation between the grayscale value of each pixel and the grayscale mean, and determine the pixels whose grayscale deviation is within the deviation range as normal pixels, and determine the pixels whose grayscale deviation is outside the deviation range as abnormal pixels;
[0011] Determine whether there are other abnormal pixels in the eight neighborhoods of each abnormal pixel. If not, filter the abnormal pixel; if so, construct a connected component composed of the abnormal pixels.
[0012] Connected components with an area smaller than a preset area threshold are filtered, while connected components with an area greater than or equal to the preset area threshold are retained, resulting in a preprocessed image.
[0013] Optionally, the preset area threshold is determined through the following steps:
[0014] Collect cable surface sheath image samples; the samples cover real defect areas and noise areas;
[0015] Each sample image is labeled to distinguish between real defect areas and noise areas;
[0016] Calculate the area of each marked region, and statistically analyze the area distribution function of the actual defect and the area distribution function of the noise respectively;
[0017] Based on the area distribution function of the real defects and the area distribution function of the noise, a classification error rate function is constructed with the goal of minimizing the classification error rate.
[0018] Solving the classification error rate function yields the area value that minimizes the classification error rate, which is then used as a preset area threshold.
[0019] Optionally, dividing the cable surface sheath image into multiple regions includes:
[0020] Set size to The sliding window, with a step size Multiple areas are formed by sliding on the image of the cable surface sheath.
[0021] Optionally, if present, constructing a connected component composed of anomalous pixels includes:
[0022] If any abnormal pixel has other abnormal pixels in its eight-neighborhood, obtain the set of other abnormal pixels in its eight-neighborhood, select an abnormal pixel from the set of other abnormal pixels as the next checkpoint, exclude the abnormal pixels that have been checked, recursively check the eight-neighborhood of the next checkpoint until no new connected abnormal pixels can be found, and classify all checked abnormal pixels into the same connected component.
[0023] Optionally, the filtering process for the abnormal pixel includes:
[0024] Replace the gray value of the abnormal pixel with the average gray value of all normal pixels in its eight neighborhoods.
[0025] Optionally, the filtering process for connected components with areas smaller than a preset area threshold includes:
[0026] Determine a target connected region with an area smaller than a preset area threshold, and replace the gray values of all pixels within the target connected region with the average gray value of all normal pixels within the target connected region.
[0027] Optionally, after obtaining the preprocessed image, the method further includes:
[0028] Defect detection is performed on the preprocessed image, and the defect detection results are output.
[0029] In a second aspect, the present invention provides a cable surface sheath image preprocessing apparatus, comprising:
[0030] The image acquisition module is used to acquire images of the surface sheath of cables on the production line;
[0031] The region division module is used to divide the cable surface sheath image into multiple regions;
[0032] The deviation range determination module is used to calculate the gray mean and standard deviation σ of all pixels in each region, and determine the deviation range based on the 3σ criterion.
[0033] The pixel determination module is used to calculate the grayscale deviation between the grayscale value of each pixel and the grayscale mean, and to determine the pixels whose grayscale deviation is within the deviation range as normal pixels, and the pixels whose grayscale deviation is not within the deviation range as abnormal pixels.
[0034] The abnormal pixel processing module is used to determine whether there are other abnormal pixels in the eight neighborhoods of each abnormal pixel. If there are no other abnormal pixels, the abnormal pixel is filtered; if there are other abnormal pixels, a connected component composed of abnormal pixels is constructed.
[0035] The connected component processing module is used to filter connected components with an area smaller than a preset area threshold, and retain connected components with an area greater than or equal to the preset area threshold to obtain a preprocessed image.
[0036] Thirdly, the present invention provides a computer device, the computer device including a memory and a processor, the memory storing a computer program, the processor executing the computer program to implement a cable surface sheath image preprocessing method as described in any one of the first aspects.
[0037] Fourthly, the present invention provides a computer-readable storage medium storing a computer program, wherein a processor executes the computer program to implement a cable surface sheath image preprocessing method as described in any one of the first aspects.
[0038] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0039] This application provides a method for preprocessing cable surface sheath images. By dividing the cable surface sheath image into multiple local regions, calculating the mean grayscale value and standard deviation of each region, and adaptively determining the deviation range based on the 3σ criterion of normal distribution, pixels with grayscale deviations exceeding this range are identified as abnormal pixels. This overcomes the uneven illumination and reflection interference caused by the curved surface of the cable. Bright areas automatically use a higher threshold, while dark areas automatically use a lower threshold, avoiding false negatives and false negatives caused by fixed thresholds. Then, by determining whether other abnormal pixels exist within the eight-neighborhood of an abnormal pixel, isolated noise points are accurately distinguished from connected abnormal pixels. Isolated noise points are directly filtered, while connected abnormal pixels are constructed into connected domains. Finally, based on the comparison between the area of the connected domain and a preset area threshold, small noise areas with areas smaller than the threshold are filtered, while potential defect areas with areas greater than or equal to the threshold are retained. This achieves differentiated processing of "noise filtering and defect retention," thereby reducing the false alarm rate and false negative rate of subsequent defect detection. Attached Figure Description
[0040] To more clearly illustrate the technical solutions of the exemplary embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly described below. It should be understood that the following drawings only show some embodiments of the present invention and should not be considered as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort. In the drawings:
[0041] Figure 1 A schematic flowchart of a cable surface sheath image preprocessing method provided in an embodiment of this application;
[0042] Figure 2 This is a schematic diagram of an eight-neighborhood provided for an embodiment of this application;
[0043] Figure 3 Another flowchart illustrating the cable surface sheath image preprocessing method provided in this application embodiment;
[0044] Figure 4 This is a schematic diagram of the structure of a cable surface sheath image preprocessing device provided in an embodiment of this application. Detailed Implementation
[0045] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the embodiments and accompanying drawings. The illustrative embodiments and descriptions of this invention are only for explaining this invention and are not intended to limit this invention.
[0046] To address the issue of uneven illumination and reflection interference caused by the curved surface characteristics of cables, resulting in high false alarm and false negative rates in subsequent defect detection, this application provides a method for preprocessing images of cable surface sheaths. Please refer to... Figure 1 This is a schematic flowchart of a cable surface sheath image preprocessing method provided in an embodiment of this application. The following is a description of... Figure 1 The image preprocessing method for the cable surface sheath shown is introduced.
[0047] S1. Acquire images of the cable surface sheath.
[0048] In practice, industrial cameras can be used to acquire real-time images of the cable sheaths on the production line, or to acquire images of the cable sheaths of randomly selected samples. Line scan or area scan cameras can be used, with appropriate resolution configured according to the required inspection accuracy. The acquired cable sheath images are either grayscale or color images; if color, they must be converted to grayscale before further processing.
[0049] S2. Divide the cable surface sheath image into multiple regions.
[0050] In one possible embodiment, the size is set to The sliding window, with a step size Slide across the image of the cable's surface sheath to create multiple areas.
[0051] In the specific implementation process, let the size of the cable surface sheath image be... (where w is the width and h is the height), the number N of regions obtained by the sliding window is calculated by the following formula:
[0052] (1)
[0053] in, This indicates rounding down to the nearest integer.
[0054] In this embodiment of the application, the entire image is divided into multiple overlapping regions, each region being of size [missing information]. Pixels. Due to step size The size is smaller than the sliding window size s, and there is overlap between adjacent regions. This can prevent defects from falling exactly on the region boundary and being missed, while ensuring that the statistical information of each region has a sufficient sample size.
[0055] S3. Calculate the mean gray value and standard deviation σ of all pixels in each region, and determine the deviation range based on the 3σ criterion.
[0056] In the specific implementation process, for each For a given area, calculate the mean and standard deviation of the grayscale values.
[0057] The formula for calculating the grayscale mean is as follows:
[0058] (2)
[0059] The formula for calculating the deviation is as follows:
[0060] (3)
[0061] The formula for calculating standard deviation is as follows:
[0062] (4)
[0063] in, Indicates the grayscale mean. express The pixel grayscale value of a point. express The deviation between the grayscale value of a pixel and its mean grayscale value. Indicates the region The standard deviation.
[0064] According to the standard normal distribution, the gray value of each pixel is in The probability within the range is 1. That is:
[0065] (5)
[0066] Where p represents the probability that the gray value of a pixel falls within a certain range.
[0067] Take the deviation range as According to the normal distribution, we know that:
[0068] (6)
[0069] The normal grayscale value deviation range is within The probability within is 99.73%.
[0070] S4. Calculate the grayscale deviation between the grayscale value of each pixel and the grayscale mean. Pixels with grayscale deviation within the deviation range are judged as normal pixels, and pixels with grayscale deviation outside the deviation range are judged as abnormal pixels.
[0071] In the specific implementation process, for cable images, if there are no defects, the pixel grayscale values at each location should be very close. If there is noise, the deviation between the grayscale value at the noise location and the normal grayscale value will be relatively large. If there are defects, the deviation between the grayscale value at the defect location and the normal grayscale value will also be relatively large. The deviation between the grayscale value of each pixel in each region and the grayscale mean is calculated according to formula (2), and the grayscale deviation is... Pixels within the specified range are considered normal pixels, and pixels with grayscale deviations are excluded. The pixels within are identified as abnormal pixels (noise or defects) and form a pixel set S.
[0072] S5. Determine whether there are other abnormal pixels in the eight neighborhoods of each abnormal pixel. If not, perform filtering on the abnormal pixel; if so, construct a connected component composed of abnormal pixels.
[0073] In one possible embodiment, if there are other abnormal pixels in the eight-neighborhood of any abnormal pixel, obtain the set of other abnormal pixels in its eight-neighborhood, select an abnormal pixel from the set of other abnormal pixels as the next checkpoint, exclude the abnormal pixels that have been checked, recursively check the eight-neighborhood of the next checkpoint until no new connected abnormal pixels can be found, and classify all checked abnormal pixels into the same connected region.
[0074] In one possible embodiment, if there are no other abnormal pixels in the eight-neighborhood of any abnormal pixel, the abnormal pixel is determined to be an isolated noise point, and the gray value of the abnormal pixel is replaced by the average gray value of all normal pixels in its eight-neighborhood.
[0075] In the specific implementation process, for any pixel in the pixel set S Pixels grayscale value Determine if there are other abnormal pixels (i.e., deviations exceeding) within its eight neighboring regions. (range of pixels).
[0076] Define its deviation within its eight neighborhoods as exceeding The range of abnormal pixel set is :
[0077] (7)
[0078] Represents pixels The eight-neighbor domain of the given domain is illustrated in the diagram below. Figure 2 As shown.
[0079] Scenario 1: Handling isolated noise points.
[0080] like (Empty set), indicating pixels There is no deviation exceeding 8 in the eight neighborhoods. Other abnormal pixels are identified as isolated noise points.
[0081] For isolated noise points The original gray value of the isolated noise point is replaced with the average gray value of all its eight neighboring pixels. for:
[0082] (8)
[0083] in, For pixels The number of pixels in the eight neighborhoods.
[0084] Scenario 2: Handling non-isolated outliers.
[0085] like , indicating pixels The eight neighbor memory contains more than If a pixel is found to be an isolated outlier, then that pixel is considered a non-isolated outlier.
[0086] For non-isolated outliers Take the abnormal pixels in its eight neighborhoods. Exclude those that have already been checked. Then, recalculate. The set of abnormal pixels in the eight neighborhoods :
[0087] (9)
[0088] in, express 8-neighborhood excludes source point Repeat the judgment logic of formula (7).
[0089] like (Empty set), explanation For relative to Isolated points;
[0090] like Continue recursively checking The pixels in the array are iterated until all connected abnormal pixels have been traversed.
[0091] Finally, all checked pixels with connectivity issues are grouped into the same connected component, thus completing the connected component construction.
[0092] This invention employs eight-neighborhood instead of four-neighborhood for connectivity analysis, which has clear technical significance. Considering that defects on the cable surface sheath (such as scratches and cracks) can extend in any direction, including orthogonal and diagonal directions, if four-neighborhood is used, diagonally extending defects (such as 45° scratches) will be segmented into multiple disconnected isolated points, causing the same defect to be identified as multiple small regions, and thus incorrectly filtered out because their area is less than a threshold. Eight-neighborhood can identify diagonal connectivity, ensuring that defects extending in any direction can be completely constructed into a connected domain.
[0093] Based on this, in this embodiment, a connected component is constructed through recursive eight-neighborhood checks to accurately distinguish isolated noise points from connected defect regions. For isolated noise points with no other abnormal pixels within their eight-neighborhood, the average gray value of their eight-neighborhood is directly used for replacement; for non-isolated points with other abnormal pixels within their eight-neighborhood, a complete connected component is constructed through recursive checks. Compared with existing methods that uniformly filter all pixels, this invention achieves accurate distinction between noise and defects, avoiding the problems of noise residue or defect blurring caused by "one-size-fits-all" filtering.
[0094] S6. Filter the connected components whose area is less than the preset area threshold, and retain the connected components whose area is greater than or equal to the preset area threshold to obtain the preprocessed image.
[0095] In the specific implementation process, an area threshold is preset in the offline stage to distinguish between noise areas and potential defect areas. During the cable production process, interference noise (such as dust and salt-and-pepper noise) usually manifests as isolated, small-area abnormal pixel sets (usually 1-3 pixels), while real defects (such as scratches, bulges, and skin tears) usually have a certain area and continuous shape (usually more than 5 pixels). Therefore, the area threshold can effectively distinguish between the two.
[0096] After obtaining the connected components of each region in the cable surface sheath image, the area of each connected component is calculated. If the area of any connected component is greater than or equal to a preset area threshold, the connected component is identified as a potential defect region and is retained without filtering. If the area of any connected component is less than the preset area threshold, the connected component is identified as a noise region and is filtered.
[0097] In one possible embodiment, the step of filtering connected components with an area smaller than a preset area threshold includes:
[0098] Determine the target connected component whose area is smaller than a preset area threshold, and use the area of the target connected component... The grayscale value of all normal pixels within the region replaces the grayscale value of all pixels within the target connected region. Here, normal pixels refer to pixels with a deviation within... Pixels within the range.
[0099] In this embodiment, the grayscale value of all pixels within the noise region is directly replaced by the average grayscale value of normal pixels, rather than through simple smoothing. This completely eliminates the noise region and prevents residual noise from affecting subsequent defect detection. The replacement value is derived from the statistics of normal pixels within the local area where the noise region is located, accurately reflecting the lighting conditions and texture features of that area. The replaced pixel value transitions naturally with the surrounding normal pixels, avoiding block effects or artifacts. Only the noise region is replaced, while potential defect areas are preserved without any processing. This ensures that the original grayscale information and edge morphology of the real defect are completely preserved, avoiding the problem of blurred or eliminated defect features in existing technologies.
[0100] In one possible embodiment, the preset area threshold can be determined as follows:
[0101] Method 1: Set a preset area threshold based on the required detection accuracy and production experience.
[0102] For example, for standard cable products, the preset area threshold can be set to 5 pixels. This value can be adjusted according to different product specifications; for example, it can be set to 3 pixels for thin cables and 10 pixels for thick cables. This method is simple and easy to implement, and suitable for application scenarios with stable production specifications.
[0103] Method 2: Collect cable surface sheath image samples; label each sample image to distinguish between real defect areas and noise areas; calculate the area of each labeled area, and statistically analyze the area distribution function of real defects and the area distribution function of noise respectively; based on the area distribution function of real defects and the area distribution function of noise, construct a classification error rate function with the goal of minimizing the classification error rate; solve the classification error rate function to obtain the area value that minimizes the classification error rate, and use it as a preset area threshold.
[0104] In the implementation process, a large number of cable surface sheath image samples were collected, with no fewer than 1000 samples, covering various real defects (scratches, bulges, tears, bubbles, etc.) and various interference noises (dust, salt-and-pepper noise, etc.). Image annotation tools were used to annotate each sample at the pixel level, marking real defect areas as defects and noise areas as noise. The pixel area of each annotated region was calculated, and the area distribution of each region was statistically analyzed. Based on the statistical results, the area distribution functions of real defects and noise were fitted to obtain the data.
[0105] Let the area distribution function of the real defect be... The area distribution function of the noise is The classification error rate function is:
[0106]
[0107] Among them, the first item The second term represents the probability of misclassifying a real defect as noise (false negative rate). This represents the probability of misclassifying noise as a defect (false alarm rate). Solve for... The optimal area threshold is obtained.
[0108] In this embodiment, the goal is to minimize the classification error rate. It considers both types of errors: misclassifying real defects as noise (missed detection) and misclassifying noise as defects (false alarm). An optimal balance between these two types of errors is achieved through optimization, avoiding the problem of traditional methods that neglect one aspect for the other. The threshold is determined based on sample data and optimization theory. The threshold selection process is scientific and objective, avoiding the subjective arbitrariness and uncertainty caused by setting thresholds based on experience in traditional methods.
[0109] In one possible embodiment, after obtaining the preprocessed image, the method further includes: performing defect detection on the preprocessed image and outputting the defect detection result.
[0110] In practice, there are various methods for defect detection, such as threshold segmentation and deep learning methods.
[0111] Considering the dependence of deep learning methods on large amounts of labeled data and GPU computing power, as a preferred embodiment, a threshold segmentation method is used to binarize the preprocessed image, marking pixels with gray values below the threshold as potential defect pixels; connected component analysis is performed on the binarized image to calculate the area, aspect ratio, roundness, and other geometric features of each connected component; connected components with an area greater than or equal to 5 pixels are identified as real defects, and the defect type is determined based on geometric features: aspect ratios greater than 3 are identified as scratches, aspect ratios less than 2 are identified as bulges or abrasions, and roundness greater than 0.9 is identified as bubbles; the defect detection results are then output.
[0112] In this embodiment, the preprocessing methods in steps S1-S6 effectively filter out noise in the cable surface image, significantly increase the grayscale difference between the defect area and the normal area, and make the illumination more uniform. Therefore, the preprocessed image has the following characteristics: clear defect features, clean background, and uniform illumination. Under these conditions, simple global threshold segmentation can achieve high-precision defect detection without complex model training and inference processes, avoiding the dependence of deep learning methods on large amounts of labeled data and GPU computing power. Preprocessing and detection work synergistically: preprocessing ensures the complete preservation of defect features and the clean and uniform background, providing high-quality input for detection; threshold segmentation ensures the real-time performance and interpretability of detection. Together, they achieve online, real-time, and high-precision detection of cable sheath defects, meeting the online detection requirements of 200 meters per minute for cable production lines.
[0113] In one possible embodiment, the size of the sliding window in S1 can be determined based on empirical values, or it can be determined in the following way:
[0114] Cable surface sheath image samples are collected, and the cable surface sheath image preprocessing method (i.e. steps S1-S6) and the same defect detection method (such as threshold segmentation) provided in this application embodiment are applied to the samples using different window sizes (all even numbers greater than 10, such as s=12, 14, 16, 18, 20). The detection accuracy (such as precision, recall, F1 score, etc.) under each candidate window size is statistically analyzed.
[0115] Then, the optimal window size is determined using any of the following strategies:
[0116] Strategy 1 (Optimal Accuracy): Select the window size that yields the highest detection accuracy as the optimal window size. This strategy aims for the best detection results and is suitable for applications with extremely high accuracy requirements.
[0117] Strategy 2 (Efficiency First): Select multiple candidate window sizes that achieve a detection accuracy of a preset threshold (e.g., above 99%), and choose the smallest one as the optimal window size. This strategy prioritizes computational efficiency while ensuring detection accuracy, making it suitable for online detection scenarios with high real-time requirements.
[0118] Please refer to Figure 3This is another schematic diagram of the cable sheath image preprocessing method provided in this application embodiment. Specifically adapted to the curved imaging characteristics and detection requirements of cable sheath surface images, it employs three core mechanisms: adaptive anomaly recognition based on local grayscale statistics, eight-neighbor recursive connected domain analysis, and area-based selective processing. While preserving various defect features of the sheath surface to the greatest extent possible, it efficiently filters various interference noises and artifacts from the production environment and imaging equipment, optimizing image quality and defect feature recognition. This avoids false alarms and missed detections in subsequent defect detection from the source, significantly improving the accuracy and stability of cable sheath surface defect detection. The detection precision fully meets the quality control standards of industrial production, providing reliable image preprocessing technology support for the automated and intelligent detection of cable sheath defects.
[0119] Those skilled in the art will understand that the image preprocessing method provided by the present invention is not only applicable to cable surface sheath images, but can also be extended to the surface defect detection preprocessing of other cylindrical objects (such as pipes and rods) and curved objects (such as spheres and curved shells), as long as the surface image of the object has uneven lighting, reflection interference, or needs to distinguish between noise and defects.
[0120] Based on the same inventive concept, please refer to Figure 4 This application also provides a cable surface sheath image preprocessing apparatus, the apparatus comprising:
[0121] The image acquisition module is used to acquire images of the surface sheath of cables on the production line;
[0122] The region division module is used to divide the cable surface sheath image into multiple regions;
[0123] The deviation range determination module is used to calculate the gray mean and standard deviation σ of all pixels in each region, and determine the deviation range based on the 3σ criterion.
[0124] The pixel determination module is used to calculate the grayscale deviation between the grayscale value of each pixel and the grayscale mean value, and to determine the pixels with grayscale deviation within the deviation range as normal pixels, and the pixels with grayscale deviation outside the deviation range as abnormal pixels.
[0125] The abnormal pixel processing module is used to determine whether there are other abnormal pixels in the eight neighborhoods of each abnormal pixel. If there are no other abnormal pixels, the abnormal pixel is filtered; if there are other abnormal pixels, a connected component composed of abnormal pixels is constructed.
[0126] The connected component processing module is used to filter connected components with an area smaller than a preset area threshold, and retain connected components with an area greater than or equal to the preset area threshold to obtain a preprocessed image.
[0127] Optionally, the preset area threshold is determined through the following steps:
[0128] Collect cable surface sheath image samples; the samples cover real defect areas and noise areas;
[0129] Each sample image is labeled to distinguish between real defect areas and noise areas;
[0130] Calculate the area of each marked region, and statistically analyze the area distribution function of the actual defect and the area distribution function of the noise respectively;
[0131] Based on the area distribution function of real defects and the area distribution function of noise, a classification error rate function is constructed with the goal of minimizing the classification error rate.
[0132] Solving the classification error rate function yields the area value that minimizes the classification error rate, which is then used as the preset area threshold.
[0133] Optionally, the region division module is specifically used for:
[0134] Set size to The sliding window, with a step size Slide across the image of the cable's surface sheath to create multiple areas.
[0135] Optionally, the abnormal pixel processing module is specifically used for:
[0136] If any abnormal pixel has other abnormal pixels in its eight-neighborhood, obtain the set of other abnormal pixels in its eight-neighborhood, select an abnormal pixel from the set of other abnormal pixels as the next checkpoint, exclude the abnormal pixels that have been checked, recursively check the eight-neighborhood of the next checkpoint, until no new connected abnormal pixels can be found, and classify all checked abnormal pixels into the same connected component.
[0137] Optionally, the abnormal pixel processing module is specifically used for:
[0138] Replace the gray value of the abnormal pixel with the average gray value of all normal pixels in its eight neighborhoods.
[0139] Optionally, the connected component processing module is specifically used for:
[0140] Determine a target connected region with an area smaller than a preset area threshold, and replace the gray values of all pixels within the target connected region with the average gray value of all normal pixels within the target connected region.
[0141] Optionally, the device also includes a defect detection module, which is used to perform defect detection on the preprocessed image after obtaining the preprocessed image and output the defect detection result.
[0142] It should be noted that each module in the cable surface sheath image preprocessing device in this embodiment corresponds one-to-one with each step in the cable surface sheath image preprocessing method in the aforementioned embodiment. Therefore, the specific implementation of this embodiment can refer to the implementation of the aforementioned cable surface sheath image preprocessing method, and will not be repeated here.
[0143] Based on the same inventive concept, this application also provides a computer device, which includes a processor, a memory, and a computer program stored in the memory. The computer program is executed by the processor to implement the aforementioned cable surface sheath image preprocessing method.
[0144] Based on the same inventive concept, this application also provides a computer storage medium storing a computer program, which is executed by a processor to implement the aforementioned cable surface sheath image preprocessing method.
[0145] In some embodiments, the computer-readable storage medium may be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, flash memory, magnetic surface memory, optical disk, or CD-ROM; or it may be a device including one or any combination of the above-mentioned memories. The computer may be a variety of computing devices, including smart terminals and servers.
[0146] In some embodiments, executable instructions may take the form of a program, software, software module, script, or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a standalone program or as a module, component, subroutine, or other unit suitable for use in a computing environment.
[0147] As an example, executable instructions may, but do not necessarily, correspond to files in the file system. They may be stored as part of a file that holds other programs or data, for example, in one or more scripts in a Hyper Text Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple collaborative files (e.g., a file that stores one or more modules, subroutines, or code sections).
[0148] As an example, executable instructions can be deployed to execute on a single computing device, or on multiple computing devices located in one location, or on multiple computing devices distributed across multiple locations and interconnected via a communication network.
[0149] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or system. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or system that includes that element.
[0150] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0151] The above specific embodiments further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above are merely specific embodiments of the present invention and are not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for preprocessing images of cable surface sheaths, characterized in that, include: Acquire images of the cable surface sheath; The image of the cable surface sheath is divided into multiple regions; Calculate the mean gray value and standard deviation σ of all pixels in each region, and determine the deviation range based on the 3σ criterion; Calculate the grayscale deviation between the grayscale value of each pixel and the grayscale mean, and determine the pixels whose grayscale deviation is within the deviation range as normal pixels, and determine the pixels whose grayscale deviation is outside the deviation range as abnormal pixels; Determine whether there are other abnormal pixels in the eight neighborhoods of each abnormal pixel. If not, filter the abnormal pixel; if so, construct a connected component composed of the abnormal pixels. Connected components with an area smaller than a preset area threshold are filtered, while connected components with an area greater than or equal to the preset area threshold are retained, resulting in a preprocessed image.
2. The method for preprocessing cable surface sheath images according to claim 1, characterized in that, The preset area threshold is determined through the following steps: Collect cable surface sheath image samples; the samples cover real defect areas and noise areas; Each sample image is labeled to distinguish between real defect areas and noise areas; Calculate the area of each marked region, and statistically analyze the area distribution function of the actual defect and the area distribution function of the noise respectively; Based on the area distribution function of the real defects and the area distribution function of the noise, a classification error rate function is constructed with the goal of minimizing the classification error rate. Solving the classification error rate function yields the area value that minimizes the classification error rate, which is then used as a preset area threshold.
3. The method for preprocessing cable surface sheath images according to claim 1, characterized in that, The step of dividing the cable surface sheath image into multiple regions includes: Set size to The sliding window, with a step size Multiple areas are formed by sliding on the image of the cable surface sheath.
4. The method for preprocessing cable surface sheath images according to claim 1, characterized in that, If such a region exists, a connected component consisting of abnormal pixels is constructed, including: If any abnormal pixel has other abnormal pixels in its eight-neighborhood, obtain the set of other abnormal pixels in its eight-neighborhood, select an abnormal pixel from the set of other abnormal pixels as the next checkpoint, exclude the abnormal pixels that have been checked, recursively check the eight-neighborhood of the next checkpoint until no new connected abnormal pixels can be found, and classify all checked abnormal pixels into the same connected component.
5. The method for preprocessing cable surface sheath images according to claim 1, characterized in that, The filtering process for the abnormal pixel includes: Replace the gray value of the abnormal pixel with the average gray value of all normal pixels in its eight neighborhoods.
6. The method for preprocessing cable surface sheath images according to claim 1, characterized in that, The filtering process for connected components with areas smaller than a preset area threshold includes: Determine a target connected region with an area smaller than a preset area threshold, and replace the gray values of all pixels within the target connected region with the average gray value of all normal pixels within the target connected region.
7. The method for preprocessing cable surface sheath images according to claim 1, characterized in that, After obtaining the preprocessed image, the method further includes: Defect detection is performed on the preprocessed image, and the defect detection results are output.
8. A cable surface sheath image preprocessing device, characterized in that, include: The image acquisition module is used to acquire images of the surface sheath of cables on the production line; The region division module is used to divide the cable surface sheath image into multiple regions; The deviation range determination module is used to calculate the gray mean and standard deviation σ of all pixels in each region, and determine the deviation range based on the 3σ criterion. The pixel determination module is used to calculate the grayscale deviation between the grayscale value of each pixel and the grayscale mean, and to determine the pixels whose grayscale deviation is within the deviation range as normal pixels, and the pixels whose grayscale deviation is not within the deviation range as abnormal pixels. The abnormal pixel processing module is used to determine whether there are other abnormal pixels in the eight neighborhoods of each abnormal pixel. If there are no other abnormal pixels, the abnormal pixel is filtered; if there are other abnormal pixels, a connected component composed of abnormal pixels is constructed. The connected component processing module is used to filter connected components with an area smaller than a preset area threshold, and retain connected components with an area greater than or equal to the preset area threshold to obtain a preprocessed image.
9. A computer device, characterized in that, The computer device includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement a cable surface sheath image preprocessing method as described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, and the processor executes the computer program to implement a cable surface sheath image preprocessing method as described in any one of claims 1-7.