A method for detecting a core end face
By employing binary threshold segmentation, clustering, adaptive segmentation, and flood filling algorithms in the core end face inspection, combined with template matching, automated detection of whether the core has been cut and the number of cuts has been achieved, solving the problem of difficulty in visual inspection and saving manpower.
Patent Information
- Application Number
- CN202310453473.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-25
- Publication Date
- 2026-11-27
- Estimated Expiration
- 2043-04-25
AI Technical Summary
During the stripping process of the wire core, it is difficult to visually detect whether the wire core has been cut for an extended period of time, and the cutting situation cannot be effectively detected under special conditions, which affects the use of the wire core.
By acquiring the original image, setting the ROI, using binary thresholding and clustering to eliminate interference, and combining adaptive segmentation algorithm, flood filling algorithm and template matching, the automatic detection of the core end face is achieved.
It has achieved automated detection of whether the wire core has been cut and the number of cuts, saving manpower and improving detection efficiency.
Smart Images

Figure CN117132530B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of wire core testing, and more specifically, to a method for testing the end face of a wire core. Background Technology
[0002] A wire core is wrapped with a sheath. When processing the wire core into a wire bundle, it needs to be cut and the sheath stripped with a knife. When using a blade to strip the sheath, the wire core may be cut off due to excessive cutting, affecting its use. When performing a large number of stripping operations, it is impossible to conduct long-term inspection with the naked eye, and it is also impossible to inspect the cutting situation with the naked eye alone under special conditions. Summary of the Invention
[0003] The purpose of this invention is to provide a method for detecting the end face of a wire core, which can determine whether the wire core has been cut and the number of cuts by detecting the end face of the wire core. Furthermore, this method achieves automated detection and saves manpower.
[0004] To solve the above-mentioned technical problems, the technical solution adopted by the present invention is as follows:
[0005] A method for detecting the end face of a wire core includes the following steps:
[0006] S1. Obtain the original image to be detected. In the original image, set the Region of Interest (ROI) and segment the suspected wire core region within the ROI using a binary threshold segmentation method. Within the suspected wire core region, use clustering to eliminate interference and obtain the coarse positioning region of the wire core. S2. Within the coarse positioning region of the wire core, use an adaptive segmentation algorithm to segment the edges of the wire core to obtain a binary image. Within the binary image, connect the segmented edges into a whole image. Obtain the bounding rectangle of the whole image and use it as the precise positioning region of the wire core. S3. In the original image, use a flood filling algorithm within the coarse positioning region of the wire core. S4. Remove interference around the wire core to obtain a suspected wire core image; S5. Register the image within the precisely located area with the suspected wire core image to obtain a registered binary image; S6. Establish a standard circle, perform template matching and positioning between the standard circle and the registered binary image, and determine the matching score. If the score is greater than the threshold, it is determined to be a wire core. At the same time, set the pixel values in the connected area around the positioning position in the binary image to 0, and increment the wire core counter data by 1; After the matching is completed, determine whether the final recorded data of the wire core counter is consistent with the preset number. If it is, output OK; otherwise, output NG.
[0007] In some embodiments of the present invention, the adaptive segmentation algorithm specifically includes the following steps:
[0008] The ROI is smoothed using median filtering. Then, a pixel is selected sequentially from left to right and from top to bottom within the processed ROI. The average gray value of each pixel's neighborhood is calculated and then subtracted by a fixed parameter value to obtain the result value. The result value is compared with the gray value of the selected pixel. If the result value is greater than the gray value, the neighborhood gray value is set to 255; otherwise, it is set to 0.
[0009] In some embodiments of the present invention, the process of connecting the segmented edges into a single image includes:
[0010] For a binary image, read the grayscale value of each pixel sequentially from left to right in each row. If the grayscale value is 255 and the grayscale value of its surrounding neighborhood is also 255, then record its coordinates I. left Then, for the same row, read the grayscale values of pixels sequentially from right to left. If the grayscale value is 255 and the grayscale value of its surrounding neighbors is also 255, record its coordinates I. right If I right >I left Then connect I left and I right Finally, the scattered binary edges of the wire cores are connected into a large region, resulting in a precisely located wire core region.
[0011] In some embodiments of the present invention, the specific steps of the flood filling algorithm include:
[0012] Create a copy of the original image. In the copy image, select one pixel from left to right for each row as a seed point. Read the gray value of the pixel. If the gray value is relatively dark and the gray values of the neighboring pixels around the seed point are also relatively dark, and the difference between the gray values of the neighboring pixels and the gray value of the seed point does not exceed the threshold, then mark the gray value of the seed point as 0. If the difference between the gray values of the seed point and the neighboring pixels does not meet the threshold, then do not change the gray value of the seed point. Finally, the interference around the core is eliminated, and the image of the suspected core spot is retained.
[0013] In some embodiments of the present invention, the registration steps specifically include:
[0014] The image within the precisely located area is compared pixel by pixel with the suspected wire core image after being filled with water. For each pixel, if its grayscale value is 255 in the image within the precisely located area and the pixel value in the suspected wire core image after being filled with water is greater than 0, then the grayscale value of that pixel is set to 255; otherwise, the grayscale value is set to 0.
[0015] In some embodiments of the present invention, the process of matching the standard circle with the registered image includes:
[0016] In the registered image, the standard circle is slid across the image sequentially, and the matching response value between the circle and the template of the registered image is calculated at each position. The pixel with the largest response value is found, and the maximum response value is compared with the set matching threshold. If the maximum response value is greater than the matching threshold, the number of cores is incremented by 1, and the pixel values around the pixel are set to 0 to avoid repeated participation in the next matching. The previous matching operation is continued until the number of operations reaches the set number of cores, or the maximum matching response value is less than the set value.
[0017] In some embodiments of the present invention, the diameter of the standard circle is slightly smaller than the diameter of the end face of the wire core.
[0018] Compared with the prior art, the present invention has at least the following advantages or beneficial effects:
[0019] This invention proposes a method for detecting the end face of a wire core. The method involves acquiring an original image to be detected, setting a Region of Interest (ROI) within the original image, segmenting the suspected wire core region within the ROI using a binary thresholding method, then using clustering to eliminate interference and obtain a coarse location region for the wire core, thus narrowing the detection area. An adaptive segmentation algorithm is then used to segment the edges of the wire core, obtaining a binary image. The segmented edges are then connected to form a single image. Based on this single image, a precise location region for the wire core is obtained, further narrowing the detection area. A flood filling algorithm is then used to remove interference around the wire core, obtaining a suspected wire core image. Finally, the single image and the suspected wire core image are registered. The process involves obtaining a registered image, establishing a standard circle, and then performing template matching and positioning between the standard circle and the registered image. The matching score is then calculated. If the score is greater than a threshold, the image is identified as a wire core, and the pixel values within its region are set to 0, while the wire core counter is incremented by 1. If the score is less than the threshold, the image is identified as a cut wire core, the wire core counter is not recorded, and the pixel values within its region are set to 0. After matching, the final recorded data of the wire core counter is checked against a preset number. If they match, "OK" is output; otherwise, "NG" is output. This method achieves automated detection and saves manpower by detecting the wire core end face to determine whether the wire core has been cut and the number of cuts. Attached Figure Description
[0020] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0021] Figure 1 This is a flowchart of an embodiment of a method for detecting the end face of a wire core according to the present invention;
[0022] Figure 2 This is a schematic diagram of the original image of an embodiment of a method for detecting the end face of a wire core according to the present invention;
[0023] Figure 3 This is a schematic diagram of a suspected wire core area image in an embodiment of a method for detecting the end face of a wire core according to the present invention;
[0024] Figure 4 This is a schematic diagram of a coarse positioning region image of a wire core, representing an embodiment of a wire core end face detection method according to the present invention.
[0025] Figure 5 This is a schematic diagram of a precise positioning area image of a wire core in an embodiment of a method for detecting the end face of a wire core according to the present invention.
[0026] Figure 6 This is a schematic diagram of a suspected wire core image, representing an embodiment of a method for detecting the end face of a wire core according to the present invention.
[0027] Figure 7 This is a schematic diagram of a registration image from an embodiment of a method for detecting the end face of a wire core according to the present invention;
[0028] Figure 8 This is a schematic diagram of the matching result image of an embodiment of the detection method for the end face of a wire core according to the present invention. Detailed Implementation
[0029] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. The components of the embodiments of this application described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.
[0030] Example
[0031] Please see Figure 1 The method for detecting the end face of a wire core includes the following steps:
[0032] Step S1: Obtain the original image to be detected. In the original image, set the ROI and use binary thresholding to segment the suspected wire core region within the ROI. Use clustering to eliminate interference within the suspected wire core region to obtain the coarse positioning region of the wire core.
[0033] In the above-described step of obtaining the original image to be inspected, a camera or other photographic device can be used to photograph the end face of the wire core to obtain an image of the wire core end face, which will serve as the original image to be inspected. Please refer to [link to relevant documentation]. Figure 2Considering the large number of elements in the captured image, preliminary localization of the wire core area is necessary. Therefore, this method involves setting a search ROI in the original image and using binary thresholding within the search ROI to segment out the suspected wire core area. Please refer to [link to relevant documentation]. Figure 3 Then, clustering is used to eliminate interference, resulting in a coarse positioning region for the wire core. Please refer to [link / reference]. Figure 4 .
[0034] Step S2: Within the coarse positioning area of the wire core, the edge of the wire core is segmented using an adaptive segmentation algorithm to obtain a binary image. Within the binary image, the segmented edges are connected to form a whole image. The bounding rectangle of the whole image is obtained based on the whole image and used as the precise positioning area of the wire core.
[0035] Considering the long detection time consumed when using the coarse core localization area described above for subsequent operations, and the need to further narrow down the detection area, an adaptive segmentation algorithm is used to segment the edges of the core within the obtained coarse core localization area to obtain a binary image. The segmented edges are then connected into a whole within the binary image. The bounding rectangle of the whole image is obtained based on this whole image. Here, the bounding rectangle is the minimum bounding rectangle, which refers to the maximum range of several two-dimensional shapes represented by two-dimensional coordinates. Specifically, it is the rectangle whose lower boundary is defined by the maximum and minimum x-coordinates, maximum and minimum y-coordinates of each vertex of a given two-dimensional shape. The area contained within this rectangle serves as the precise core localization area. (See [link to relevant documentation]). Figure 5 This further reduces the detection area and saves detection time.
[0036] S3. In the original image, the flood filling algorithm is used to remove the interference around the wire core in the coarse positioning area of the wire core to obtain a suspected wire core image.
[0037] Considering that interfering elements may appear around the wire core image during the above steps, and since the flood fill algorithm achieves segmentation by finding identical regions based on the difference between pixel grayscale values, the flood fill algorithm is used here to remove interference around the wire core, thereby obtaining a suspected wire core image. Please refer to [link to relevant documentation]. Figure 6 .
[0038] S4. Register the image within the precisely located area with the suspected wire core image to obtain a registered binary image.
[0039] Registration is the process of mapping two images from a dataset to each other using a spatial transformation, ensuring that points at corresponding spatial locations in the two images correspond one-to-one, thus achieving information fusion. Therefore, this method uses registration to fuse information from the overall image and the suspected core image to obtain an accurate core image. Please refer to [link to relevant documentation]. Figure 7 .
[0040] S5. Establish a standard circle, perform template matching and positioning between the standard circle and the registered binary image, and determine the matching score. If the score is greater than the threshold, it is determined to be a core. At the same time, the pixel values of the connected regions around the positioning position in the binary image are set to 0, and the core counter data is incremented by 1. After the matching is completed, determine whether the final recorded data of the core counter is consistent with the preset number. If it is, output OK; otherwise, output NG.
[0041] In the above steps, a standard circle is established, with a diameter slightly smaller than the diameter of the wire core end face. This standard circle is then matched and positioned with the registration image to achieve a matching score. Here, the matching and positioning score essentially refers to sequentially placing the standard circle within the white area of the wire core image. (See [link to relevant documentation]). Figure 8 If the white area completely contains the standard circle, a score is awarded, and the core counter data is incremented by 1. If the white area does not completely contain the standard circle, no score is awarded, and the core counter is not recorded. Finally, the processor determines whether the data recorded by the core counter is consistent with the preset number. If they are consistent, it means that the core has not been cut; otherwise, it means that the core has been cut, and the number of cores cut is determined by the core counter.
[0042] In some embodiments of the present invention, the adaptive segmentation algorithm specifically includes the following steps:
[0043] The ROI is smoothed using median filtering. Then, one pixel is taken from left to right and from top to bottom of the processed ROI, and the average gray value of the neighborhood of each pixel is calculated. The average gray value of the neighborhood is then subtracted from the average gray value of the neighborhood. The result value is then compared with the original value of the pixel. If the result value is greater than the original value, the gray value of the neighborhood is set to 255. If it is less than the original value, it is set to 0.
[0044] The adaptive segmentation algorithm described above uses median filtering to smooth the ROI. Then, it takes one pixel from left to right and from top to bottom of the processed ROI and calculates the average gray value of the neighborhood of each pixel. Then, it subtracts a fixed parameter value to obtain the result value. The result value is compared with the original value of the pixel. If the result value is greater than the original value, the gray value of the neighborhood is set to 255. If it is less than the original value, it is set to 0, thereby segmenting the edge of the line core.
[0045] In some embodiments of the present invention, the process of connecting the segmented edges into a single image includes:
[0046] For a binary image, for each row, read the grayscale value of each pixel sequentially from left to right. If the grayscale value is 255 and the grayscale value of its surrounding neighborhood is also 255, then record its coordinates I. leftThen, for the same row, read the grayscale value of each pixel sequentially from right to left. If the grayscale value is 255 and the grayscale value of its surrounding neighbors is also 255, record its coordinates I. right If I right >I left Then connect I left and I right .
[0047] Obtain coordinate I through the above steps. left and I right By connecting them, the scattered binary edges of the wire cores are finally connected into a large area, thereby obtaining a precisely located wire core area and further narrowing the detection range.
[0048] In some embodiments of the present invention, the specific steps of the above-mentioned flood filling algorithm include:
[0049] Create a copy of the original image. In the copy image, select one pixel from left to right in each row as a seed point. Read the gray value of the pixel. If the gray value is relatively dark and the gray values of the neighboring pixels around the seed point are also relatively dark, and the difference between the gray value of the neighboring pixels and the gray value of the seed point does not exceed the threshold, then mark the gray value of the seed point as 0. If the difference between the gray values of the seed point and the neighboring pixels does not meet the threshold, then do not change the gray value of the seed point.
[0050] The purpose of this detection method is to use a flood filling algorithm to eliminate interference around the wire core, thereby obtaining images of suspected wire core spots and further determining the true wire core image.
[0051] In some embodiments of the present invention, the above-mentioned registration steps specifically include:
[0052] The image within the precisely located area is compared pixel by pixel with the suspected wire core image after being filled with water. For each pixel, if its grayscale value is 255 in the image within the precisely located area and the pixel value in the suspected wire core image after being filled with water is greater than 0, then the grayscale value of that pixel is set to 255; otherwise, the grayscale value is set to 0.
[0053] Considering that inconsistent fill colors may occur when using the flood fill algorithm, which may affect subsequent steps, the registration step here includes: when the gray value of the suspected wire core image is greater than 0, the gray value is set to 255, otherwise the gray value is set to 0. Here, gray value 0 is black and gray value 255 is white, thus obtaining an image with only black and white.
[0054] In some embodiments of the present invention, the diameter of the standard circle is slightly smaller than the diameter of the end face of the wire core.
[0055] In the above steps, the standard circle needs to be placed within the white area of the wire core image for matching. Therefore, the diameter of the standard circle cannot be greater than or equal to the diameter of the wire core end face, nor can it be too small. If it is too small, it will be impossible to determine the cut wire core. Therefore, the diameter of the standard circle should be set slightly smaller than the diameter of the wire core end face.
[0056] In summary, embodiments of the present invention propose a method for detecting the end face of a wire core. This method involves acquiring an original image to be detected, setting a Region of Interest (ROI) within the original image, segmenting the suspected wire core region within the ROI using a binary thresholding method, then using clustering to eliminate interference and obtain a coarse location region for the wire core, thus narrowing the detection area. An adaptive segmentation algorithm is then used to segment the edges of the wire core, obtaining a binary image. The segmented edges are then connected into a single image. Based on this single image, a precise location region for the wire core is obtained, further narrowing the detection area. A flood filling algorithm is then used to remove interference around the wire core, obtaining a suspected wire core image. Finally, the single image and the suspected wire core image are registered. The process involves obtaining a registered image, establishing a standard circle, and then performing template matching and positioning between the standard circle and the registered image. The matching score is then calculated. If the score is greater than a threshold, the image is identified as a wire core, and the pixel values within its region are set to 0, while the wire core counter is incremented by 1. If the score is less than the threshold, the image is identified as a cut wire core, the wire core counter is not recorded, and the pixel values within its region are set to 0. After matching, the final recorded data of the wire core counter is checked against a preset number. If they match, "OK" is output; otherwise, "NG" is output. This method achieves automated detection and saves manpower by detecting the wire core end face to determine whether the wire core has been cut and the number of cuts.
[0057] It will be apparent to those skilled in the art that this application is not limited to the details of the exemplary embodiments described above, and that this application can be implemented in other specific forms without departing from the spirit or essential characteristics of this application. Therefore, the embodiments should be considered illustrative and non-limiting in all respects, and the scope of this application is defined by the appended claims rather than the foregoing description. Thus, all variations falling within the meaning and scope of equivalents of the claims are intended to be included within this application. No reference numerals in the claims should be construed as limiting the scope of the claims.
Claims
1. A method for detecting the end face of a wire core, characterized in that, Includes the following steps: S1. Obtain the original image to be detected. In the original image, set the ROI and use the binary threshold segmentation method to segment the suspected wire core area within the ROI. Use the clustering method to eliminate interference within the suspected wire core area to obtain the coarse positioning area of the wire core. S2. Within the coarse positioning area of the wire core, an adaptive segmentation algorithm is used to segment the edges of the wire core to obtain a binary image. Within the binary image, the segmented edges are connected to form a whole image. The bounding rectangle of the whole image is obtained based on the whole image and used as the precise positioning area of the wire core. S3. In the original image, the flood filling algorithm is used to remove the interference around the wire core in the coarse positioning area of the wire core to obtain a suspected wire core image. S4. Register the image within the precisely located area with the suspected wire core image to obtain a registered binary image; S5. Establish a standard circle, perform template matching and positioning between the standard circle and the registered binary image, and determine its matching score. If the score is greater than the threshold, it is determined to be a core. At the same time, the pixel values in the connected area around the positioning position in the binary image are set to 0, and the core counter data is incremented by 1. After matching is complete, check whether the final recorded data of the wire core counter is consistent with the preset number. If it is, output OK; otherwise, output NG. The specific registration steps include: The image within the precisely located area is compared pixel by pixel with the suspected wire core image after being filled with water. For each pixel, if its grayscale value is 255 in the image within the precisely located area and the pixel value in the suspected wire core image after being filled with water is greater than 0, then the grayscale value of that pixel is set to 255; otherwise, the grayscale value is set to 0.
2. The method for detecting the end face of a wire core according to claim 1, characterized in that, The specific steps of the adaptive segmentation algorithm include: Median filtering is used to smooth the ROI; Select one pixel from left to right and from top to bottom of the processed ROI, calculate the average gray value of each pixel's neighborhood, and then subtract the fixed parameter value to obtain the result value. The result value is compared with the gray value of the selected pixel. If the result value is greater than the gray value, the gray value of the neighborhood is set to 255, and if it is less than the gray value, it is set to 0.
3. The method for detecting the end face of a wire core according to claim 1, characterized in that, The process of connecting the segmented edges into a single image includes: For a binary image, read the grayscale value of each pixel sequentially from left to right in each row. If the grayscale value is 255 and the grayscale value of its surrounding neighborhood is also 255, then record its coordinates. Then, for the same row, read the grayscale values of pixels sequentially from right to left. If the grayscale value is 255 and the grayscale value of its surrounding neighbors is also 255, record its coordinates. ,if Then connect and .
4. The method for detecting the end face of a wire core according to claim 1, characterized in that, The specific steps of the flood filling algorithm include: Create a copy of the original image. In the copy image, select one pixel from left to right in each row as a seed point. Read the gray value of the pixel. If the gray value is relatively dark and the gray values of the neighboring pixels around the seed point are also relatively dark, and the difference between the gray value of the neighboring pixels and the gray value of the seed point does not exceed the threshold, then mark the gray value of the seed point as 0. If the difference between the gray values of the seed point and the neighboring pixels does not meet the threshold, then do not change the gray value of the seed point.
5. The method for detecting the end face of a wire core according to claim 1, characterized in that, The process of matching the standard circle with the registered image includes: In the registered image, the standard circle is slid in the image sequentially, and the matching response value between the standard circle and the template of the registered image is calculated at each position. The pixel with the largest response value is found, and the largest response value is compared with the set matching threshold. If it is greater than the matching threshold, the number of cores is increased by 1, and the pixel values around the pixel are set to 0. Continue performing the previous matching operation until the number of operations reaches the set number of wire cores, or the maximum matching response value is less than the set value.
6. The method for detecting the end face of a wire core according to claim 1, characterized in that, The diameter of the standard circle is slightly smaller than the diameter of the end face of the wire core.
Citation Information
Patent Citations
Image identification-based round log counting method
CN106485708A
