Method and device for detecting stripe overlapping or crossing phenomenon in image
By combining multi-level image preprocessing and thinning algorithms with global spacing verification, the problem of detecting overlapping or crossing stripes in industrial products has been solved, achieving efficient and accurate quality inspection. It is applicable to industrial products such as rubber conveyor belts, fiber composite materials, and textile fabrics.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- UNIV OF JINAN
- Filing Date
- 2025-12-26
- Publication Date
- 2026-05-01
AI Technical Summary
Existing technologies are insufficient for efficiently and accurately detecting overlapping or crossing of stripes in industrial products, resulting in low product quality inspection efficiency, high subjectivity, and susceptibility to interference from uneven lighting, noise, and foreign objects, making it difficult to meet the needs of modern production lines.
Multi-level image preprocessing (gamma transform, histogram equalization, and local adaptive binarization) is employed to enhance image contrast. The Zhang-Suen thinning algorithm is used to extract the stripe skeleton with a single pixel width. The global average spacing is calculated by the threading method. The eight-neighbor feature and maximum connectivity depth are used for verification to eliminate noise and foreign object interference and determine the true overlapping or crossing defects.
It improves the accuracy and reliability of detection, effectively identifies stripe overlap or intersection defects, is applicable to different materials and imaging conditions, and is suitable for quality inspection on industrial production lines.
Smart Images

Figure CN121962026A_ABST
Abstract
Description
Method and apparatus for detecting overlapping or crossing stripes in an image Technical Field
[0001] This invention relates to a method and apparatus for detecting overlapping or crossing stripes in an image, and is particularly suitable for automated visual inspection of the laying quality of internal or surface stripes (cords) during the production process of industrial products (such as rubber conveyor belts, fiber composite materials, and textile fabrics), belonging to the field of image processing technology. Background Technology
[0002] In various industrial sectors such as rubber conveyor belts, fiber material processing, composite material manufacturing, and textiles, the regularity of the stripe pattern (such as cord) as the core reinforcing skeleton material directly determines the mechanical properties, structural stability, and service life of the final product. Stripes are typically required to be laid parallel and equidistant. Any overlap or intersection (i.e., local crossing, overlapping, or misalignment of adjacent or non-adjacent stripes) can lead to localized stress concentration, significantly reducing the product's tensile and tear resistance, and easily causing breakage and other safety hazards during use. For example, overlapping cords in rubber conveyor belts can lead to increased localized wear and stress imbalance during operation, significantly shortening the service life.
[0003] Currently, stripe defect detection relies heavily on manual visual inspection, which suffers from low efficiency, high subjectivity, and susceptibility to missed defects due to fatigue, making it difficult to meet the demands of modern high-speed production lines. Furthermore, the types, densities, and imaging environments of stripes vary significantly across different application scenarios, posing challenges to automated inspection. Existing image processing methods often fall short in terms of versatility, robustness, and accuracy, struggling to accurately identify minute overlapping or intersecting defects, and are susceptible to interference from uneven lighting, noise, and foreign objects.
[0004] Therefore, there is an urgent need for an automated method and device that can accurately, efficiently and stably detect stripe overlap or intersection in images, so as to achieve real-time online monitoring and control of product quality. Summary of the Invention
[0005] To address the aforementioned problems, this invention proposes a method and apparatus for detecting overlapping or crossing phenomena of stripes in an image, which can effectively identify true overlapping or crossing defects of stripes and eliminate abnormal interference such as foreign objects and noise.
[0006] The technical solution adopted by the present invention to solve its technical problem is as follows: Firstly, an embodiment of the present invention provides a method for detecting stripe overlap or intersection in an image, comprising the following steps: Step S1, preprocessing the image to be detected to extract a binary image of the foreground stripes; Step S2, thinning the binary image to obtain a stripe skeleton image with a single pixel width; Step S3, calculating the global average spacing of the stripes in the image based on the stripe skeleton image using a threading method; Step S4, traversing the pixels in the stripe skeleton image, and based on the eight-neighborhood features of the pixels, initially judging and marking potential overlap or intersection points as a set of suspected defect points; Step S5, for each suspected overlap or intersection point in the set of suspected defect points, calculating its maximum connectivity depth, and comparing and verifying the maximum connectivity depth with a threshold set based on the global average spacing to eliminate interference caused by noise or foreign objects, and finally determining the actual overlap or intersection defect.
[0007] As one possible implementation of this embodiment, step S1 includes the following steps: Step S11, performing gamma transformation on the image to be detected to improve the overall brightness of the image and enhance the details in the dark areas; Step S12, performing histogram equalization on the gamma-transformed image to enhance the contrast between the bright and dark areas; Step S13, performing local adaptive binarization processing on the equalized image to extract the binary image of the foreground stripes.
[0008] As a possible implementation of this embodiment, the Zhang-Suen thinning algorithm is used for thinning in step S2. Step S2 includes the following steps: Step S21, converting the pixel values of the binary image from 255 to 1, so that the image contains only two pixel values: 0 and 1; Step S22, performing the first round of thinning scan, traversing each foreground pixel in the image, and marking the pixel as to be deleted if the following conditions are met simultaneously: Condition A1: The sum of the neighboring pixel values S satisfies 2≤S≤6; Condition A2: At least one pixel value is 0 in the area directly above, to the left, and below the pixel; Condition A3: The pixel value is 0 in the area directly to the left, below, and to the right of the pixel. In step S23, perform a second round of thinning scan, traversing the foreground pixels again. If the following conditions are met simultaneously, mark the pixel as to be deleted: Condition B1: The sum of the values of the neighboring pixels S satisfies 2≤S≤6; Condition B2: At least one pixel above, to the right, and to the left of the pixel has a value of 0; Condition B3: At least one pixel above, below, and to the left of the pixel has a value of 0; In step S24, set all pixel values marked for deletion to 0; In step S25, repeat steps S22 and S23 until no new pixels are marked for deletion, obtaining a striped skeleton image with a single pixel width.
[0009] As one possible implementation of this embodiment, step S3 includes the following steps: Step S31, on the stripe skeleton image, N columns are uniformly selected along the vertical stripe direction, where N≥4; Step S32, for each column, the position of all skeleton pixels is detected, the difference between the row coordinates of adjacent skeleton pixels is calculated, and the local line spacing set of that column is obtained; Step S33, the local line spacing set of each column is sorted, the extreme values at the beginning and end are removed, and the arithmetic mean of the remaining 60% of the data is calculated as the representative line spacing of that column; Step S34, the representative line spacing of all columns is combined into a set, sorted again and the extreme values at the beginning and end are removed, and the average value of the remaining values is taken to obtain the global average stripe spacing of the entire image.
[0010] As a possible implementation of this embodiment, step S4 includes the following steps: Step S41, using a breadth-first search strategy to traverse the stripe skeleton image, starting from the foreground pixel, and traversing each continuous stripe line completely; Step S42, during the traversal, for each foreground pixel P, extracting the pixel values in its 3×3 eight-neighbor area; Step S43, based on the eight-neighbor pixel values, determining whether the current pixel is a potential overlap or intersection point; Step S44, marking and recording all pixels determined to be potential overlap or intersection points to form a set of suspected defect points, wherein the suspected defect points include the following information: coordinate position, distribution of eight-neighbor pixel values, and the stripe line number to which they belong.
[0011] As one possible implementation of this embodiment, the process of determining whether the current pixel is a potential overlap or intersection point includes: counting the number of changes from 0 to 1 or from 1 to 0 in the eight-neighborhood sequence; if the number of changes is greater than or equal to 6, then the point is marked as a suspected overlap or intersection point; checking whether any of the following situations exist in the eight-neighborhood: Situation C1: all rows in the eight-neighborhood are 1; Situation C2: all rows in the eight-neighborhood are 1; Situation C3: all columns in the eight-neighborhood are 1; Situation C4: all columns in the eight-neighborhood are 1; if any of the above situations exist, then the point is marked as a suspected overlap or intersection point.
[0012] As a possible implementation of this embodiment, step S5 includes the following steps: Step S51, for each suspected overlap or intersection point in the suspected defect point set, perform a depth-first search along the two extension directions of its corresponding stripe line; Step S52, record the number of foreground pixels continuously connected from that point along each direction; Step S53, take the larger of the two connection lengths and add the connection lengths of the two directions to obtain the maximum connection depth of that point. Step S54: Set the judgment threshold. Where k is a coefficient, with a value ranging from 1.2 to 2.0. The global average spacing of the stripes in the image; step S55, ... Compared with T, if If so, it is determined to be a true overlap or cross defect; if If it is found to be a false defect, it will be excluded.
[0013] Secondly, an embodiment of the present invention provides an apparatus for detecting overlapping or crossing stripes in an image, comprising: an image preprocessing module for preprocessing the image to be detected and extracting a binary image of the foreground stripes; a skeleton extraction module for thinning the binary image to obtain a stripe skeleton image with a single pixel width; a spacing calculation module for calculating the global average spacing of the stripes in the image based on the stripe skeleton image using a threading method; a suspected point detection module for traversing the pixels in the stripe skeleton image, and preliminarily judging and marking potential overlapping or crossing points based on the eight-neighborhood features of the pixels, as a set of suspected defect points; and a authenticity verification module for calculating the maximum connectivity depth of each suspected overlapping or crossing point in the set of suspected defect points, and comparing the maximum connectivity depth with a threshold set based on the global average spacing to verify and eliminate interference caused by noise or foreign objects, and finally determine the real overlapping or crossing defects.
[0014] Thirdly, an electronic device provided by an embodiment of the present invention includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the method described above for detecting overlapping or crossing stripes in an image.
[0015] Fourthly, embodiments of the present invention provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method described above for detecting stripe overlap or intersection phenomena in an image.
[0016] One of the above technical solutions has the following advantages or beneficial effects: 1. It adopts a two-level discrimination strategy, firstly screening suspected overlapping or intersection points based on local features, and then eliminating interference through spacing verification, thereby improving the detection accuracy and reliability.
[0017] 2. Through multi-level image preprocessing (gamma transform, histogram equalization, and dual-window local binarization), the image contrast is effectively enhanced, overcoming the effects of uneven illumination and noise, and exhibiting strong robustness.
[0018] 3. The classic Zhang-Suen thinning algorithm is used to extract the single-pixel skeleton, which preserves the topological structure of the stripes and simplifies subsequent analysis.
[0019] 4. Calculate the global average spacing using the threading method, eliminate the influence of extreme values, and obtain a reliable benchmark value.
[0020] 5. By combining eight-neighborhood features and spacing verification, it utilizes both the microscopic features of pixel distribution at the overlap point and the macroscopic laws of spacing changes, which can effectively distinguish between real defects and interference such as foreign objects and noise.
[0021] 6. The method has a clear process and adjustable parameters, making it suitable for stripe detection under different materials, densities, and imaging conditions. It has good versatility and is easy to integrate into automated production lines for online quality inspection.
[0022] 7. The provided device has a clear structure and modular design, which facilitates maintenance and upgrades, and can be widely used in quality inspection systems on industrial production lines. Attached Figure Description
[0023] Figure 1 is a flowchart illustrating a method for detecting stripe overlap or intersection in an image according to an exemplary embodiment; Figure 2 is a schematic diagram illustrating an apparatus for detecting stripe overlap or intersection in an image according to an exemplary embodiment; Figure 3 is a flowchart illustrating a specific implementation of detecting stripe overlap or intersection in an image according to an exemplary embodiment; Figure 4 is an image of tire cord texture according to an exemplary embodiment; Figure 5 is a schematic diagram of a structural element for horizontal stripe morphological filtering according to an exemplary embodiment; Figure 6 is a schematic diagram of the eight-neighborhood of a pixel P according to an exemplary embodiment; Figure 7 is a schematic diagram of stripe overlap or intersection according to an exemplary embodiment; Figure 8 is a schematic diagram of local features (eight-neighborhood) of an overlap or intersection point according to an exemplary embodiment; Figure 9 is an actual image of tire cord overlap or intersection according to an exemplary embodiment. Detailed Implementation
[0024] To more clearly illustrate the technical features of the present invention, the present invention will be described in detail below through specific embodiments and in conjunction with the accompanying drawings.
[0025] As shown in Figure 1, an embodiment of the present invention provides a method for detecting overlapping or crossing stripes in an image, comprising the following steps: Step S1, preprocessing the image to be detected to extract a binary image of the foreground stripes; Step S2, thinning the binary image to obtain a stripe skeleton image with a single pixel width; Step S3, calculating the global average spacing of the stripes in the image using a threading method based on the stripe skeleton image; Step S4, traversing the pixels in the stripe skeleton image, and preliminarily judging and marking potential overlapping or crossing points based on the eight-neighborhood features of the pixels, as a set of suspected defect points; Step S5, calculating the maximum connectivity depth of each suspected overlapping or crossing point in the set of suspected defect points, and comparing the maximum connectivity depth with a threshold set based on the global average spacing to verify and eliminate interference caused by noise or foreign objects, and finally determining the actual overlapping or crossing defects.
[0026] As one possible implementation of this embodiment, step S1 includes the following steps: Step S11, performing gamma transformation on the image to be detected to improve the overall brightness of the image and enhance the details in the dark areas; Step S12, performing histogram equalization on the gamma-transformed image to enhance the contrast between the bright and dark areas; Step S13, performing local adaptive binarization processing on the equalized image to extract the binary image of the foreground stripes.
[0027] The preprocessing operations are performed in the following order: first, gamma transformation is performed to enhance overall brightness; then histogram equalization is performed to enhance contrast; and finally, local adaptive binarization is performed to extract foreground fringes.
[0028] As one possible implementation of this embodiment, the formula for the gamma transform is: ,in, γ is the gray value of the input image at coordinates (x, y), and γ is an adjustable parameter, 0 < γ < 1.
[0029] As one possible implementation of this embodiment, the histogram equalization includes: calculating the gray-level histogram of the original image and counting the frequency of each gray-level k. : ,in For indicator functions, when A grayscale image is set to 1 if the value is 1 and 0 otherwise. Size is The pixel-level grayscale range is [0, ... ], =256; Calculate the normalized histogram to obtain the probability of each gray level. : Where M×N is the total number of pixels in the image; calculate the cumulative distribution function. : Based on the cumulative distribution function, a gray-level mapping relationship is established, and the transformation function is obtained. : , among which, among which This represents a floor operation, where L is the total number of gray levels; it maps the gray values of each pixel in the original image to a specific value using a mapping relationship. The transformation is performed to obtain the enhanced output image.
[0030] As one possible implementation of this embodiment, the local adaptive binarization is processed using two windows of different sizes: the first window has a size of a×a, where a = 1.5h and h is the known average fringe spacing; the second window has a size of b×b, where b = 8h~10h; for each window, the local threshold is calculated using the Otsu method and binarized to obtain two binary images.
[0031] After obtaining two binary images, morphological filtering is performed on the two binary images respectively. The morphological filtering includes performing erosion, dilation, and opening / closing operations of erosion in sequence. The two filtered binary images are then subjected to a logical AND operation to generate the final binary image.
[0032] As a possible implementation of this embodiment, the Zhang-Suen thinning algorithm is used for thinning in step S2. Step S2 includes the following steps: Step S21, converting the pixel values of the binary image from 255 to 1, so that the image contains only two pixel values: 0 and 1; Step S22, performing the first round of thinning scan, traversing each foreground pixel in the image, and marking the pixel as to be deleted if the following conditions are met: Condition A1: The sum of the neighboring pixel values S satisfies 2≤S≤6. The sum of the neighboring pixel values S is calculated by summing the pixel values in the eight neighboring pixels of the current pixel as the center; Condition A2: There is at least one pixel directly above, to the left, or directly below the current pixel. The value is 0; Condition A3: At least one pixel to the left, right, and left of the pixel has a value of 0; Step S23: Perform a second round of thinning scan, traverse the foreground pixels again, and mark the pixel as to be deleted if the following conditions are met simultaneously: Condition B1: The sum of the values of the neighboring pixels S satisfies 2≤S≤6; Condition B2: At least one pixel to the top, right, and left of the pixel has a value of 0; Condition B3: At least one pixel to the top, bottom, and left of the pixel has a value of 0; Step S24: Set all pixel values marked for deletion to 0; Step S25: Repeat steps S22 and S23 until no new pixels are marked for deletion, and obtain a striped skeleton image with a single pixel width.
[0033] Before performing the thinning process, it also includes checking whether there are non-zero and non-255 pixel values in the binary image. If so, normalization is performed.
[0034] The goal of the thinning process in step S2 is to obtain a single-pixel width skeleton that preserves the original stripe topology, providing a basis for subsequent spacing calculation and feature analysis.
[0035] As one possible implementation of this embodiment, step S3 includes the following steps: Step S31, on the striped skeleton image, N columns are uniformly selected along the vertical stripe direction, where N≥4, and the value of N ranges from 4 to 10, and these columns are uniformly distributed on the image; Step S32, for each column, the positions of all skeleton pixels are detected, the difference between the row coordinates of adjacent skeleton pixels is calculated, and the local line spacing set of that column is obtained. If the number of detected skeleton pixels is less than 2, the column is skipped and does not participate in the calculation of the global average spacing; Step S33, the local line spacing set of each column is sorted, the extreme values at the beginning and end are removed, and the arithmetic mean of the remaining 60% of the data is calculated as the representative line spacing of that column; Step S34, the representative line spacing of all columns is combined into a set, sorted again, and the extreme values at the beginning and end are removed, and the average value of the remaining values is taken to obtain the global average stripe spacing of the entire image. The calculated global average stripe spacing is used as the benchmark value for subsequent verification to distinguish between normal spacing and abnormal spacing.
[0036] As a possible implementation of this embodiment, step S4 includes the following steps: Step S41, using a breadth-first search strategy to traverse the stripe skeleton image, starting from the foreground pixel, and traversing each continuous stripe line completely; Step S42, during the traversal, for each foreground pixel P, extracting the pixel values in its 3×3 eight-neighbor area; Step S43, based on the eight-neighbor pixel values, determining whether the current pixel is a potential overlap or intersection point; Step S44, marking and recording all pixels determined to be potential overlap or intersection points to form a set of suspected defect points, wherein the suspected defect points include the following information: coordinate position, distribution of eight-neighbor pixel values, and the stripe line number to which they belong.
[0037] As one possible implementation of this embodiment, the process of determining whether the current pixel is a potential overlap or intersection point includes: counting the number of changes from 0 to 1 or from 1 to 0 in the eight-neighborhood sequence; if the number of changes is greater than or equal to 6, then the point is marked as a suspected overlap or intersection point; checking whether any of the following situations exist in the eight-neighborhood: Situation C1: all rows in the eight-neighborhood are 1; Situation C2: all rows in the eight-neighborhood are 1; Situation C3: all columns in the eight-neighborhood are 1; Situation C4: all columns in the eight-neighborhood are 1; if any of the above situations exist, then the point is marked as a suspected overlap or intersection point.
[0038] The breadth-first search strategy is implemented as follows: initialize an access marker array, and mark all pixels as unvisited; traverse each pixel in the image, and if the current pixel is a foreground pixel and has not been visited, start the breadth-first search from it; during the search process, mark the visited foreground pixels as visited, and check the eight-neighbor features of each pixel.
[0039] As a possible implementation of this embodiment, step S5 includes the following steps: Step S51, for each suspected overlap or intersection point in the suspected defect point set, perform a depth-first search along the two extension directions of its corresponding stripe line; Step S52, record the number of foreground pixels continuously connected from that point along each direction; Step S53, take the larger of the two connection lengths and add the connection lengths of the two directions to obtain the maximum connection depth of that point. Step S54: Set the judgment threshold. Where k is a coefficient, with a value ranging from 1.2 to 2.0. The global average spacing of the stripes in the image; step S55, ... Compared with T, if If so, it is determined to be a true overlap or cross defect; if If it is found to be a false defect, it will be excluded.
[0040] As one possible implementation of this embodiment, the specific implementation of the depth-first search is as follows: with the suspected overlapping or intersection point as the center, search in both upward and downward directions; during the search process, move along the connected path of the stripe skeleton until encountering background pixels or visited pixels; record the number of foreground pixels passed during the search process.
[0041] As one possible implementation of this embodiment, step S5 further includes a step of further verifying suspected overlaps or intersections: calculating the estimated value of the local actual line spacing in the area near the suspected overlap or intersection, and comparing the value with the global average spacing. If the local actual line spacing is significantly smaller than the global average spacing, the determination that the point is a real defect is strengthened.
[0042] The final output of step S5 includes: the location coordinates, defect type, and confidence score of all real overlapping or cross defects in the image.
[0043] As shown in Figure 2, an embodiment of the present invention provides an apparatus for detecting overlapping or crossing stripes in an image, comprising: an image preprocessing module for preprocessing the image to be detected and extracting a binary image of the foreground stripes; a skeleton extraction module for thinning the binary image to obtain a stripe skeleton image with a single pixel width; a spacing calculation module for calculating the global average spacing of the stripes in the image based on the stripe skeleton image using a threading method; a suspected point detection module for traversing the pixels in the stripe skeleton image, and based on the eight-neighborhood features of the pixels, preliminarily judging and marking potential overlapping or crossing points as a set of suspected defect points; and a authenticity verification module for calculating the maximum connectivity depth of each suspected overlapping or crossing point in the set of suspected defect points, and comparing the maximum connectivity depth with a threshold set based on the global average spacing to verify and eliminate interference caused by noise or foreign objects, and finally determine the true overlapping or crossing defect.
[0044] Taking tire cord detection as an example (hereinafter, "tire cord" and "cord" correspond to "stripes" in the above technical solution), as shown in Figure 3, the specific process of detecting stripe overlap or intersection phenomena in the image based on the above technical solution is as follows.
[0045] Step 1: Preprocess the input image.
[0046] The preprocessing includes: enhancing the overall brightness of the image through gamma transform, enhancing the contrast between bright and dark areas through histogram equalization, and extracting a binary image of the foreground texture through local adaptive binarization.
[0047] 1.1: Gamma Transform for Input Tire Cord Image As shown in Figure 4, perform the gamma transformation: (1), where As an adjustable parameter, γ=0.5 is used to stretch the grayscale of dark areas, improve the overall brightness, enhance the visibility of low-light areas, and make the curtain line more distinct from the background.
[0048] 1.2: Window size setting, based on the actual average spacing of texture stripes. (Unit: pixels), determines the baseline size of the subsequent processing window, and the spacing of the texture stripes. The approximate spacing obtained by prior observation is used for binarization, but the accuracy of the spacing is not high. The subsequent average cord spacing requires high accuracy and needs to be calculated.
[0049] 1.3: Histogram Equalization. Histogram equalization is performed on the gamma-transformed image to make the gray-level distribution more uniform, further enhancing the contrast between bright and dark areas and highlighting the details of the curtain edges. Specifically, this involves calculating the image's gray-level histogram, normalized histogram, and cumulative distribution function, and establishing a gray-level mapping relationship to finally obtain the equalized image. Calculate the gray-level histogram of the original image and count the gray levels in the image. (0 The frequency of occurrence of ) . Let . Represents grayscale level If the number of pixels is: (2), of which For indicator functions, when A grayscale image is set to 1 if the value is 1 and 0 otherwise. Size is The pixel-level grayscale range is [0, ... ](generally =256); Calculate the normalized histogram, and convert the frequencies... Divide by the total number of pixels in the image To obtain the probability of each gray level. : (3) Calculate the cumulative distribution function. Defined as from gray level 0 to The sum of probabilities: (4) The function is monotonically increasing and its value range is [0, 1]; establish the gray-scale mapping relationship based on the cumulative distribution function, and then... Mapped to the full grayscale output range [0, ], thus obtaining the transformation function : (5), of which This function represents a rounding down operation, which rounds the original grayscale level down. Mapped to new grayscale levels Output the mapped image, iterating through the input images. Each pixel Based on its original grayscale value Look up the mapping table The output image is obtained. The grayscale value at the corresponding position in the image: (6) Histogram equalization is used to distinguish between bright and dark areas and to prepare for the selection of binarization threshold.
[0050] 1.4: Local adaptive binarization. Curtain images may exhibit gradual illumination changes. The average curtain spacing h (in pixels) is obtained based on prior knowledge or a rough estimate. Binarization is performed using two different window sizes, with a smaller window size... ,in =1.5h, designed to capture local details, ensuring that stripes and background are included within the window simultaneously, large window size. Where b=9h, a wider range of grayscale background information is obtained to enhance robustness to gradual changes in illumination. At two window scales, local thresholds are calculated using Otsu's method based on the pixel grayscale distribution within the window, and the image is then processed. Binarization is performed to obtain the images respectively. and .
[0051] 1.5: Morphological filtering. To eliminate minute noise and artifacts in the image, appropriate morphological structuring elements are defined based on texture features, as shown in Figure 5. These elements are then used to filter the image. and By performing the "erosion-dilation-erosion" operation in sequence (i.e., a variant of the opening and closing operation), this combination can smooth the contours and preserve the main structure.
[0052] 1.6: Image fusion, which combines two filtered binary images. and Perform a logical AND operation, retaining only pixels that are identified as foreground in both images, to generate the final binary image. This step integrates information from different scales, suppressing noise while preserving the true nature of the cord.
[0053] Step 2: Apply Zhang to the binary image. The Suen thinning algorithm is used to extract the skeleton, resulting in the skeleton structure of the horizontal stripes.
[0054] 2.1: Pixel value normalization, transforming a binary image... The pixel value is converted from 255 to 1, so that the image contains only two pixel values: 0 (background) and 1 (foreground). For ease of calculation, 255 in the binary image is converted to 1. 2.2: The first round of thinning scan traverses each foreground pixel (value 1) in the image and checks its eight neighbors, as shown in Figure 6. If the following conditions are met, the pixel is marked as to be deleted: Condition 1: The sum of the neighboring pixel values Satisfy 2 Condition 2: At least one of the pixels directly above, to the left, or directly below the pixel is 0; Condition 3: At least one of the pixels directly to the left, below, or to the right of the pixel is 0; 2.3: Second round of fine-tuning scan, traversing the foreground pixels again, if the following condition is met, mark it as to be deleted: Condition 4: Sum of neighboring pixel values Satisfy 2 Condition 5: At least one of the pixels directly above, to the right, or to the left of the pixel is 0; Condition 6: At least one of the pixels directly above, below, or to the left of the pixel is 0; 2.4: Iterative deletion and skeleton generation: Set all pixel values marked for deletion to 0. Repeat steps 2.2 and 2.3 until no new pixels are marked for deletion, finally obtaining a skeleton image with a single pixel width. .
[0055] Step 3: Based on the skeleton structure, the average stripe spacing of the entire image is calculated using the threading method.
[0056] 3.1: Statistical analysis of column spacing in skeleton images Eight columns are uniformly selected along the vertical texture direction (usually the image column direction). For the j-th column (j=1,2,...,8), the row coordinates of all skeleton pixels are found, and the difference between adjacent coordinates is calculated to obtain the local spacing set for that column. This set is sorted, and the largest and smallest 20% of data are removed. The average of the remaining data is calculated as the representative spacing for that column. Regarding the requirement for the number of columns, the threading method requires a column with a width of one pixel. A sufficiently large number of columns is needed to eliminate the influence of abnormal situations. 3.2: Sort the line spacing sets obtained for each column, remove the largest and smallest 20% of data (extreme values), and take the arithmetic mean of the remaining 60% of data as the representative line spacing for that column. ( (For column indexes); 3.3: Global average spacing calculation, calculating the representative line spacing of all columns { The data is then grouped into a set, sorted again, and the extreme values at the beginning and end are removed. The average value of the remaining values is then calculated to obtain the average stripe spacing of the entire image. This value reflects the normal spacing level of the stripes.
[0057] Step 4: Traverse the refined stripe skeleton and make a preliminary judgment on potential overlaps and intersections based on the eight-neighborhood features of each pixel.
[0058] 4.1: Traverse the skeleton image using a breadth-first search strategy. Ignore background pixels (value 0) and pixels that have already been marked as visited. Using the foreground pixel as the seed point, traverse each continuous stripe line completely one by one; 4.2: Neighborhood feature analysis. During the traversal of each stripe line, extract the pixel values in the 3×3 eight-neighborhood of the current pixel P, as shown in Figure 6, and arrange them into a binary sequence in clockwise or counterclockwise order; 4.3: Suspected point judgment. There are two judgment rules. If either one is satisfied, it can be marked as a suspected overlapping or intersection point: Rule A: Arrange the binary sequence of the eight-neighborhood pixel values into a sequence in clockwise order, and count the number of changes from 0 to 1 or 1 to 0 in the sequence. If the number of changes is ≥6, then the point is considered to be a possible intersection point of multiple lines.
[0059] Rule B: Based on the eight-neighbor graph of pixel P in Figure 6, design the following rule: (7), (8), (9), where equation (7) indicates that all pixel values in the first or third row of Figure 6 are 1, equation (8) indicates that the first or third column of Figure 6 is 1 at the same time, and equation (9) indicates that when there exists a row or column with all values of 1, that is When the value is 1, it indicates an overlap or intersection. Based on formulas (7), (8), and (9), if all values in the first row (P0, P1, P2) or the third row (P4, P5, P6) of the eight neighboring regions are 1, or all values in the first column (P0, P6, P7) or the third column (P2, P3, P4) are 1, then P is marked as a suspected overlap or intersection point, as shown in Figure 6. Record the coordinates and neighborhood status of all suspected overlaps or intersections.
[0060] Step 5: For the potential overlaps and intersections identified in Step 4, calculate the stripe spacing in the adjacent areas, and combine it with the average stripe spacing obtained in Step 3 to eliminate interference caused by foreign objects or other anomalies, so as to finally determine whether there are real stripe overlaps or intersections in the image, as shown in Figure 7.
[0061] 5.1: Local depth search, for each suspected overlap or intersection point Perform a depth-first search (DFS) along the two extension directions (up and down) of the stripe line to which it belongs, as shown in Figure 8, and record the suspected overlap or intersection points. The maximum connectivity depth of a point is calculated by taking the larger of the two values in the two directions and adding them together. Maximum connected depth This indirectly reflects the size of the gap between two lines near that point; the smaller the gap, The smaller it is usually.
[0062] 5.2: Spacing Comparison and Judgment: Set the judgment threshold T=1.5 ,like This indicates that the stripes intersect and the gaps are small, which meets the characteristics of overlapping or crossing, and is judged to be a real defect; if This indicates that the gap is large or the connectivity is normal. It may be caused by foreign objects, noise, or normal stripe undulations. It is judged as a false defect and is excluded.
[0063] Finally, the location information of all points identified as real defects is output, which can be used to draw marker boxes on the original image. The image of overlapping or crossing of cords in the tire is shown in Figure 9, or an inspection report can be generated.
[0064] This invention performs gamma transform preprocessing on the detection image to enhance the distinction between the stripe lines and the background. In some low-brightness images, the contrast between the foreground curtain lines and the background is not obvious. By performing histogram equalization, the pixel distribution of the image is made more uniform, enhancing the contrast between bright and dark areas, thus making the stripe details clearer and improving the accuracy of subsequent stripe overlap detection.
[0065] After histogram equalization, stripe features are extracted. First, binarization and color inversion are performed to effectively extract stripe information. To address potential uneven grayscale distribution and localized over-darkness within the detection area, a local adaptive binarization method is employed. Two windows (a×a and b×b, respectively) are used for binarization. The window size is determined based on the known stripe spacing h: the side length a of the smaller window is set to 1.5 times h to ensure that both foreground stripes and background information are included; the side length b of the larger window is set to 8–10 times h to fully capture local grayscale statistical features. Finally, a logical AND operation is performed on the two binary images, and the result is inverted to obtain the final binary image.
[0066] Stripe skeleton feature extraction employs the Zhang-Suen image thinning algorithm. By thinning the binary image, a linear skeleton composed of single-pixel widths is obtained. This skeleton structure provides the basis for subsequent overlap point detection based on single-pixel widths.
[0067] Based on the refined skeleton image, the global average line spacing is calculated. According to prior knowledge, the line spacing at the actual overlap point is extremely small (usually only one pixel), and the line spacing in the adjacent area gradually decreases from far to near. By calculating the actual line spacing near suspected overlaps or intersections, false detections caused by other factors can be effectively eliminated.
[0068] A breadth-first search strategy is used to traverse each curtain line in the binary image. Background pixels (values of 0) and already visited pixels are ignored. Starting with unvisited white pixels, each curtain line is traversed sequentially. During the traversal, the pixel information within the eight-neighborhood of the current pixel is analyzed. If the pixel value within the neighborhood changes 0 / 1 more than 6 times, or if a row or column of pixels is all 1, the point is marked as a suspected overlap point, and its feature information is recorded.
[0069] For each suspected overlap point, a depth-first search is performed along its upper and lower directions to determine the cord spacing near the point. Based on this, a judgment is made: if the spacing is greater than a set threshold, it is determined to be a pseudo-overlap caused by other interference and is excluded; if the spacing is less than or equal to the threshold, it is confirmed as a real overlap, the stripe information is saved and the detection result box is output.
[0070] This invention solves the problem of high false alarm rate in stripe defect detection in complex industrial images, and significantly improves the accuracy and reliability of detection.
[0071] An electronic device provided by an embodiment of the present invention includes a processor, a memory, and a bus. The memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the memory via the bus, and the processor executes the machine-readable instructions to perform the steps of the method described above for detecting overlapping or crossing stripes in any of the images.
[0072] Specifically, the aforementioned memory and processor can be general-purpose memory and processor, without any specific limitations. When the processor runs the computer program stored in the memory, it can execute the aforementioned method for detecting overlapping or crossing stripes in an image.
[0073] Corresponding to the above application startup method, this embodiment of the invention also provides a storage medium storing a computer program, which, when run by a processor, executes the steps of the method described above for detecting overlapping or crossing stripes in any image.
[0074] 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 protection scope of the claims of the present invention.
Claims
1. A method for detecting overlapping or crossing stripes in an image, characterized in that, The process includes the following steps: Step S1, preprocessing the image to be detected to extract the binary image of the foreground stripes; Step S2, thinning the binary image to obtain a stripe skeleton image with a single pixel width; Step S3, calculating the global average spacing of the stripes in the image using the threading method based on the stripe skeleton image; Step S4, traversing the pixels in the stripe skeleton image, and preliminarily judging and marking potential overlapping or crossing points based on the eight-neighbor features of the pixels, as a set of suspected defect points; Step S5, calculating the maximum connectivity depth of each suspected overlapping or crossing point in the set of suspected defect points, and comparing the maximum connectivity depth with a threshold set based on the global average spacing to verify and determine the actual overlapping or crossing defects.
2. The method for detecting stripe overlap or intersection in an image according to claim 1, characterized in that, Step S1 includes the following steps: Step S11, performing gamma transformation on the image to be detected to improve the overall brightness of the image and enhance the details in the dark areas; Step S12, performing histogram equalization on the gamma-transformed image to enhance the contrast between the bright and dark areas; Step S13, performing local adaptive binarization processing on the equalized image to extract the binary image of the foreground stripes.
3. The method for detecting stripe overlap or intersection in an image according to claim 1, characterized in that, Step S2 employs the Zhang-Suen thinning algorithm for thinning processing. Step S2 includes the following steps: Step S21, converting the pixel values of the binary image from 255 to 1, so that the image contains only two pixel values: 0 and 1; Step S22, performing the first round of thinning scan, traversing each foreground pixel in the image, and marking the pixel as to be deleted if the following conditions are met simultaneously: Condition A1: The sum S of the neighboring pixel values satisfies 2≤S≤6; Condition A2: At least one pixel above, to the left, and below the pixel has a value of 0; Condition A3: At least one pixel to the left, below, and to the right of the pixel has a value of 0. The pixel value is 0; Step S23, perform a second round of thinning scan, and traverse the foreground pixels again. If the following conditions are met simultaneously, mark the pixel as to be deleted: Condition B1: The sum of the values of the neighboring pixels S satisfies 2≤S≤6; Condition B2: At least one pixel above, to the right, and to the left of the pixel has a value of 0; Condition B3: At least one pixel above, below, and to the left of the pixel has a value of 0; Step S24, set all pixel values marked for deletion to 0; Step S25, repeat steps S22 and S23 until no new pixels are marked for deletion, and obtain a stripe skeleton image with a single pixel width.
4. The method for detecting stripe overlap or intersection in an image according to claim 1, characterized in that, Step S3 includes the following steps: Step S31, on the striped skeleton image, N columns are uniformly selected along the vertical stripe direction, where N≥4; Step S32, for each column, the position of all skeleton pixels is detected, the difference between the row coordinates of adjacent skeleton pixels is calculated, and the local line spacing set of that column is obtained; Step S33, the local line spacing set of each column is sorted, the extreme values at the beginning and end are removed, and the arithmetic mean of the remaining 60% of the data is calculated as the representative line spacing of that column; Step S34, the representative line spacing of all columns is combined into a set, sorted again and the extreme values at the beginning and end are removed, and the average value of the remaining values is taken to obtain the global average stripe spacing of the entire image.
5. The method for detecting stripe overlap or intersection in an image according to claim 1, characterized in that, Step S4 includes the following steps: Step S41, using a breadth-first search strategy to traverse the stripe skeleton image, starting from the foreground pixel, and traversing each continuous stripe line completely one by one. Step S42: During the traversal, for each foreground pixel P, extract the pixel values within its 3×3 eight-neighborhood. Step S43: Based on the eight neighboring pixel values, determine whether the current pixel is a potential overlap or intersection point; Step S44: Mark and record all pixels determined to be potential overlaps or intersection points to form a set of suspected defect points. The suspected defect points include the following information: coordinate position, distribution of eight neighboring pixel values, and the stripe line number to which they belong.
6. The method for detecting stripe overlap or intersection in an image according to claim 5, characterized in that, The process of determining whether the current pixel is a potential overlap or intersection point includes: counting the number of changes from 0 to 1 or from 1 to 0 in the eight-neighborhood sequence; if the number of changes is greater than or equal to 6, the point is marked as a suspected overlap or intersection point; checking whether any of the following conditions exist in the eight-neighborhood: Condition C1: all rows in the eight-neighborhood are 1; Condition C2: all rows in the eight-neighborhood are 1; Condition C3: all columns in the eight-neighborhood are 1; Condition C4: all columns in the eight-neighborhood are 1; if any of the above conditions exist, the point is marked as a suspected overlap or intersection point.
7. The method for detecting stripe overlap or intersection in an image according to any one of claims 1-6, characterized in that, Step S5 includes the following steps: Step S51, for each suspected overlap or intersection point in the suspected defect point set, perform a depth-first search along the two extension directions of its corresponding stripe line; Step S52, record the number of foreground pixels continuously connected from that point along each direction; Step S53, take the larger of the two connection lengths and add the connection lengths of the two directions to obtain the maximum connection depth of that point. Step S54: Set the judgment threshold. Where k is a coefficient, with a value ranging from 1.2 to 2.
0. The global average spacing of the stripes in the image; Step S55, will Compared with T, if If so, it is determined to be a genuine overlap or cross defect; like If it is found to be a false defect, it will be excluded.
8. A device for detecting overlapping or crossing stripes in an image, characterized in that, include: The image preprocessing module is used to preprocess the image to be detected and extract the binary image of the foreground stripes; The skeleton extraction module is used to thin the binary image to obtain a striped skeleton image with a single pixel width. The spacing calculation module is used to calculate the global average spacing of the stripes in the image based on the stripe skeleton image by using the threading method. The suspected point detection module is used to traverse the pixels in the striped skeleton image, and based on the eight-neighborhood features of the pixels, preliminarily judge and mark potential overlapping or intersection points as a set of suspected defect points. The authenticity verification module is used to calculate the maximum connectivity depth of each suspected overlap or intersection point in the suspected defect point set, and compare the maximum connectivity depth with a threshold set based on the global average spacing to verify and determine the real overlap or intersection defect.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the method for detecting overlapping or crossing stripes in an image as described in any one of claims 1-7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the program implements the method for detecting overlapping or crossing stripes in an image as described in any one of claims 1-7.
Citation Information
Cited By
Cross fiber image processing method
CN121982053A