Line head defect detection method and device for line drawing and storage medium

By converting line art images into raster images and implementing a three-level verification mechanism, including vector angle filtering and clustering algorithms, the inefficiency of line end defect detection in line art images is solved, achieving fast and accurate line end defect identification and improving user experience.

CN121304581BActive Publication Date: 2026-04-21BEIJING LEXIN SHENGWEN TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
BEIJING LEXIN SHENGWEN TECH CO LTD
Filing Date
2025-10-09
Publication Date
2026-04-21

Smart Images

  • Figure CN121304581B_ABST
    Figure CN121304581B_ABST
Patent Text Reader

Abstract

This invention provides a method, apparatus, and storage medium for detecting line-end defects in line art drawings, comprising: converting the target line art drawing into a raster image; converting the raster image into a binary skeleton image; identifying potential line-end endpoints in the binary skeleton image and creating an initial set of candidate line-end points; selecting any potential line-end endpoint as the center and obtaining the nearest intersection point and the two farthest foreground points within a neighborhood window of a set size; obtaining a first updated set of candidate line-end points; obtaining a second updated set of candidate line-end points; selecting any line-end candidate point in the second updated set as the center, extracting a corresponding region of a set size from the raster image as a region of interest, inputting the region of interest into a pseudo-line-end region recognition model, and obtaining a final set of line-end points based on the recognition results. Using the detection method provided by this invention, line-end defects can be detected quickly and accurately.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer image processing technology, and to a method, apparatus and storage medium for detecting line defects in line drawings. Background Technology

[0002] Line art is a black-and-white or color original artwork that uses lines as its primary means of expression. It is widely used in design, illustration, games, and other fields as the basis for creative work. It uses lines of different shapes (thickness, solidity, curvature, straightness) to outline the contours of objects, divide space, emphasize structural proportions and dynamic textures, and does not rely on color blocks or light and shadow.

[0003] For example, Paint by Number is a popular mobile casual game where players complete artwork by filling different enclosed areas of a line drawing with color. The quality of the line drawing directly affects the user experience, especially when players zoom in on specific areas on their mobile devices. Minor imperfections in the lines (i.e., parts of the lines that extend beyond the boundaries at intersections) become noticeable, resulting in an unnatural appearance and impacting immersion and aesthetics.

[0004] Currently, line art for coloring games is primarily drawn manually by designers or generated by algorithms. However, because line art is often quite complex, designers find it difficult to completely avoid minor line defects during the drawing process, especially in high-resolution or complex compositions. Furthermore, while existing image editing software (such as Adobe Photoshop and Procreate) offers some line optimization tools (such as smoothing and erasing), manual pixel-by-pixel inspection is still necessary, which is inefficient and prone to overlooking minor flaws.

[0005] In terms of automated inspection, traditional image processing methods (such as edge detection and morphological operations) can identify line structures, but they struggle to accurately distinguish between normal lines and line defects. Existing computer-aided design (CAD) or vector graphics software (such as Adobe Illustrator), while possessing path optimization capabilities, are primarily designed for engineering drawings or vector graphics, making them unsuitable for the rasterized line art of coloring games. Furthermore, these methods typically have high computational complexity, making them unsuitable for the real-time optimization needs of mobile devices or games.

[0006] Therefore, there is a need for a method, apparatus, and storage medium for detecting line defects in line drawings, in order to at least partially solve the above-mentioned technical problems. Summary of the Invention

[0007] In view of this, embodiments of the present invention provide a method, apparatus and storage medium for detecting line end defects in line drawings, so as to at least solve one of the problems in the prior art.

[0008] In a first aspect, embodiments of the present invention provide a method for detecting line end defects in a line drawing, the detection method comprising:

[0009] Convert the target line drawing into a raster image;

[0010] The raster image is converted into a binary skeleton map;

[0011] Identify potential line endpoints in the binarized skeleton graph and create an initial set of candidate line endpoints based on all potential line endpoints;

[0012] Traverse the initial set of candidate line ends and select any potential line end point as the center. Obtain the intersection point closest to the selected potential line end point and the two farthest foreground points within a neighborhood window of a set size. Perform the first pseudo line end point filtering based on the vector angle between the intersection point and the line connecting the selected potential line end point and the two foreground points, and obtain the first updated set of candidate line ends.

[0013] Based on the first updated candidate point set, a clustering algorithm is used to perform a second pseudo-endpoint filtering to obtain the second updated candidate point set.

[0014] Traverse the second updated candidate line point set and select any candidate line point as the center. Extract the corresponding region of a set size in the raster image as the region of interest. Input the region of interest into the pseudo line point region recognition model and obtain the final set of line point points based on the recognition results.

[0015] Secondly, embodiments of the present invention also provide a device for detecting line end defects in line drawings, the device comprising:

[0016] Memory is used to store executable instructions for a computer;

[0017] A detection method for implementing the above-described technical solution when a processor executes computer-executable instructions stored in the memory.

[0018] Thirdly, embodiments of the present invention also provide a storage medium storing computer instructions, wherein the computer instructions are used to cause the computer to execute the detection method of the above-described technical solution.

[0019] According to the detection method of this invention, after a series of preprocessing steps on the target line drawing, it is converted into a binary skeleton image. Then, potential line endpoints in the binary skeleton image are identified, and an initial set of candidate line endpoints is created. Next, taking any potential line endpoint in the initial set of candidate line endpoints as the center, the nearest intersection point and the two farthest foreground points within a neighborhood window of a set size are obtained. Geometric verification is performed based on the vector angle to achieve the first filtering of pseudo line endpoints. Then, density filtering is achieved based on a clustering algorithm. Finally, the pseudo line endpoint region recognition model is used for classification verification. That is, a cascaded filtering architecture with a three-level verification mechanism is designed to remove pseudo line endpoints and achieve fast and accurate identification of line defects.

[0020] Additional advantages, objects, and features of the invention will be set forth in part in the description which follows, and will also become apparent in part to those skilled in the art upon studying the description, or may be learned by practice of the invention. The objects and other advantages of the invention can be realized and obtained by means of the structures specifically pointed out in the description and drawings.

[0021] Those skilled in the art will understand that the objectives and advantages achievable with the present invention are not limited to those specifically described above, and that the above and other objectives achievable with the present invention will become clearer from the following detailed description. Attached Figure Description

[0022] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this application, are not intended to limit the scope of the invention. The components in the drawings are not drawn to scale but are merely illustrative of the principles of the invention. For ease of illustration and description of certain parts of the invention, corresponding portions in the drawings may be enlarged, i.e., may appear larger relative to other components in an exemplary device actually manufactured according to the invention. In the drawings:

[0023] Figure 1 This is a flowchart of a detection method according to an embodiment of the present invention;

[0024] Figure 2 This is a schematic diagram of a grayscale image and a binary skeleton image during the process of converting a raster image into a binary skeleton image in a detection method according to an embodiment of the present invention;

[0025] Figure 3 This is a schematic diagram of the true and false line-end points in the initial line-end candidate point set in the detection method according to an embodiment of the present invention; wherein, the red circle indicates the true line-end point and the blue circle indicates the false line-end point;

[0026] Figure 4This is a schematic diagram of the detection method according to an embodiment of the present invention, showing the intersection point closest to the selected potential line endpoint and the two foreground points furthest from it within a neighborhood window of a set size; in this diagram, point C0 represents the selected potential line endpoint, point P0 represents the intersection point closest to the selected potential line endpoint, and points P1 and P2 represent the two foreground points furthest from the selected potential line endpoint.

[0027] Figure 5 This is a schematic diagram of the first updated candidate set of line ends, the second updated candidate set of line ends, and the final set of line ends in the detection method according to an embodiment of the present invention;

[0028] Figure 6 This is a schematic diagram of a detection device according to an embodiment of the present invention;

[0029] Figure 7 This is a schematic diagram of a detection system according to an embodiment of the present invention. Detailed Implementation

[0030] 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. Here, the illustrative embodiments and descriptions of this invention are used to explain the invention, but are not intended to limit the invention.

[0031] It should also be noted that, in order to avoid obscuring the invention with unnecessary details, only the structures and / or processing steps closely related to the solution according to the invention are shown in the accompanying drawings, while other details that are not closely related to the invention are omitted.

[0032] It should be emphasized that the term "including / comprises" as used herein refers to the presence of a feature, element, step, or component, but does not exclude the presence or addition of one or more other features, elements, steps, or components.

[0033] It should also be noted that, unless otherwise specified, the term "connection" in this article can refer not only to a direct connection, but also to an indirect connection involving an intermediary.

[0034] In the following description, embodiments of the invention will be illustrated with reference to the accompanying drawings. In the drawings, the same reference numerals represent the same or similar parts, or the same or similar steps.

[0035] First, refer to Figure 1 This application describes a method 100 for detecting line end defects in a line drawing according to an embodiment of the present application. For example... Figure 1 As shown, the detection method 100 may include steps S110 and S160.

[0036] In step S110, the target line drawing is converted into a raster image.

[0037] In step S120, the raster image is converted into a binary skeleton image.

[0038] In step S130, potential line end points in the binarized skeleton graph are identified, and an initial set of candidate line end points is created based on all potential line end points.

[0039] In step S140, the initial set of candidate line ends is traversed and any potential line end point is selected as the center. The nearest intersection point and the two farthest foreground points within a neighborhood window of a set size are obtained. Based on the vector angles between the intersection points and the lines connecting the selected potential line end point and the two foreground points, the first pseudo line end point filtering is performed to obtain the first updated set of candidate line ends.

[0040] In step S150, a second set of pseudo-line endpoints is filtered using a clustering algorithm based on the first updated candidate line point set to obtain the second updated candidate line point set.

[0041] In step S160, the second updated candidate line point set is traversed and any candidate line point is selected as the center. The corresponding area of ​​a set size in the raster image is extracted as the region of interest. The region of interest is input into the pseudo line point region recognition model, and the final set of line point points is obtained based on the recognition result.

[0042] In the embodiments of this application, firstly, the target line drawing is converted into a raster image; then, the raster image is converted into a binary skeleton image; potential line endpoints in the binary skeleton image are identified, and an initial set of candidate line endpoints is created based on all potential line endpoints; then, the initial set of candidate line endpoints is traversed and any potential line endpoint is selected as the center, and the intersection point closest to the selected potential line endpoint and the two farthest foreground points within a neighborhood window of a set size are obtained; a first pseudo-line endpoint filtering is performed based on the vector angles between the intersection point and the lines connecting the selected potential line endpoint and the two foreground points, respectively, to obtain a first updated set of candidate line endpoints; then, a second pseudo-line endpoint filtering is performed based on the first updated set of candidate line endpoints using a clustering algorithm to obtain a second updated set of candidate line endpoints; finally, the second updated set of candidate line endpoints is traversed and any line endpoint is selected as the center, and a corresponding region of a set size in the raster image is extracted as the region of interest, the region of interest is input into the pseudo-line endpoint region recognition model, and the final set of line endpoints is obtained based on the recognition results.

[0043] As can be seen from the above description, the detection method 100 according to the embodiment of this application achieves automatic removal of pseudo-thread endpoints and realizes rapid and accurate identification of thread defects through a three-level verification mechanism consisting of vector angle geometric verification, clustering algorithm density filtering, and pseudo-thread region identification model classification verification.

[0044] The following will combine Figure 1 The specific description includes the above-described steps of the detection method 100 according to the embodiments of this application.

[0045] In an embodiment of this application, step S110 converts the target line drawing into a raster image.

[0046] Specifically, to ensure a good user experience, line art in coloring games often uses vector data, such as PDF files. Therefore, converting line art in vector data formats like PDFs into raster images facilitates subsequent algorithm processing.

[0047] For example, the PyMuPDF library can be used to convert vector-based line drawings into raster images. Specifically, by controlling the DPI value of the PDF file, the resolution of the resulting bitmap can be controlled.

[0048] It is understandable that although line drawing is used as an example in step S110, and the subject of this application is for line drawing, when line defects also exist in related images in other scenes or other fields, the related images can be converted into grid images first, and then the subsequent steps can be performed in the same way to quickly and accurately detect line defects.

[0049] In an embodiment of this application, step S120 converts the raster image into a binary skeleton map.

[0050] Specifically, step S120 may include the following steps:

[0051] In step S121, the raster image can be converted to a grayscale image using the OpenCV cvtColor function. Thresholding can be performed using an adaptive method.

[0052] Step S122, refer to Figure 2 For ease of subsequent processing, the black and white colors in the grayscale image can be swapped, and then the Zhang-Suen thinning algorithm can be applied iteratively to generate a binary skeleton image.

[0053] In an embodiment of this application, step S130 identifies potential line endpoints in the binarized skeleton graph and creates an initial set of candidate line endpoints based on all potential line endpoints.

[0054] Specifically, eight-neighbor convolution operations can be used to quickly identify potential line ends.

[0055] Among them, an octagonal neighborhood refers to a pixel having 8 adjacent pixels around it, namely one pixel each on the top, bottom, left, right, and the four diagonals (top, bottom, left, right).

[0056] By performing eight-neighbor convolution operations, potential line endpoints are identified, that is, isolated points in the binary skeleton graph are found, which are points with only one neighbor in the eight-neighbor connected region.

[0057] To quickly find isolated points, a convolutional detection kernel can be defined. The convolution result of the entire image is calculated. Points with a convolution value of 11 are selected as potential line start endpoints (candidate points). All potential line start endpoints form the initial set of candidate line start points.

[0058] Alternatively, the pixels of the binarized skeleton map convolved with the set convolutional detection kernel K. Then it is necessary to ensure the pixel It is a foreground pixel, and among the remaining 8 pixels, exactly one is a foreground pixel.

[0059] Additionally, during convolution calculations, boundary handling can employ mirror padding. The initial set of candidate line start points contains both genuine line start points and pseudo-line start points.

[0060] like Figure 3 As shown, the red circle indicates the true thread start point, and the blue circle indicates the false thread start point. The areas containing the true thread start point and the false thread start point can be referred to as the valid thread start area and the false thread start area, respectively.

[0061] In the embodiments of this application, in step S140, the initial set of candidate line ends is traversed and any potential line end point is selected as the center. The intersection point closest to the selected potential line end point and the two farthest foreground points within a neighborhood window of a set size are obtained. Based on the vector angle between the intersection point and the line connecting the selected potential line end point and the two foreground points, the first pseudo line end point filtering is performed to obtain the first updated set of candidate line ends C1.

[0062] Specifically, as can be seen from step S130 above, the pseudo-line head points in the pseudo-line head region of the line drawing will also form the same characteristics as the real line head points on the skeleton drawing. In order to remove such pseudo-line head points from the initial set of candidate line head points, we can first use geometric verification to verify the validity of the potential line head endpoints in the initial set of candidate line head points through vector angle analysis.

[0063] We can iterate through the initial set of candidate line start points and select any potential line start endpoint C0. Then, we select a neighborhood window of size N*N centered at C0. Within this neighborhood window, we find the nearest intersection point P0 to point C0. An intersection point P0 is defined as one whose 8-connected neighborhood has at least 3 foreground points, such as... Figure 4 As shown. Finally, among the foreground points on the four boundaries of the N*N neighborhood window, find the two foreground points farthest from point C0, and label them as point P1 (the relatively closer point, or the second farthest point) and point P2 (the relatively farther point). Let V0 be the straight line between point C0 and point P0, V1 be the line connecting point P0 and point P1, and V2 be the line connecting point P0 and point P2. When the sum of the cosine values ​​of the angles between lines V0 and V1 and between lines V1 and V2 is less than a set value, such as 0, then point C0 is a pseudo-line start point and needs to be filtered and removed. After filtering pseudo-line start points through the above geometric verification, the initial set of candidate line start points forms the first updated set of candidate line start points C1. The size of N can be customized as needed.

[0064] It is understandable that the set value of the sum of the cosine values ​​of the included angle in the above scheme can be adjusted according to the application scenario.

[0065] In the embodiments of this application, in step S150, a clustering algorithm is used to perform a second pseudo-line endpoint filtering based on the first updated line candidate point set to obtain the second updated line candidate point set C2.

[0066] Specifically, in the first set of candidate points for updated line ends obtained through step S140, there are still a large number of pseudo line ends. Density filtering can be used, for example, by using a clustering algorithm to further remove pseudo line ends from the first set of candidate points for updated line ends, forming a second set of candidate points for updated line ends C2 after density filtering.

[0067] The DBSCAN clustering algorithm can be used to identify dense point clusters. The parameters involved in the DBSCAN clustering algorithm include the neighborhood radius of the cluster and the minimum number of points, which can be set based on different line drawings. For a found dense point cluster, if the total number of potential line endpoints exceeds a set threshold, all points in the dense point cluster are removed as pseudo-line endpoints. Figure 5 As shown, after density filtering, a second set of candidate points for updating line heads, C2, is generated.

[0068] Generally, the DBSCAN clustering algorithm includes concepts such as core points, boundary points, noise points, density reachability, and density connectivity. The general steps include: randomly selecting an unprocessed point as a starting point; if the number of points within a set neighborhood radius of this starting point is greater than a set minimum number of points, then this starting point is a core point; for each core point, a new cluster is created, adding the core point and all its density reachable points (i.e., points within a set neighborhood radius) to the new cluster; these newly added points are recursively processed until no new core points or boundary points are added to the current cluster, forming dense point clusters.

[0069] For example, taking any potential line-head endpoint in the first updated candidate line-head point set as the starting point, if the number of potential line-head endpoints within a set neighborhood radius corresponding to this starting point is greater than a set minimum number of points, then this potential line-head endpoint is a core point. For each core point, a new cluster is created, and the core point and its potential line-head endpoints within its set neighborhood radius are added to the current new cluster. These newly added potential line-head endpoints are processed recursively until no new core points or boundary points are added to the current cluster, forming dense point groups. Among them, for each core point, if a potential line-head endpoint within its set neighborhood radius is not a core point but has been previously added to a cluster, then it is a boundary point. If the total number of potential line-head endpoints in a found dense point group exceeds a set threshold, then all points in the dense point group are removed as pseudo-line-head points.

[0070] In the embodiments of this application, in step S160, the second updated candidate line point set is traversed and any candidate line point is selected as the center. A corresponding area of ​​a set size in the raster image is extracted as the region of interest. The region of interest is input into the pseudo line point region recognition model, and the final set of line points is obtained based on the recognition result.

[0071] Specifically, based on the second updated set of candidate line points C2, and using the coordinates of the candidate points and the information of the original raster image, a deep convolutional neural network (classifier) ​​can be used to filter the final candidate line points, remove candidate line points in the pseudo-line point regions, and obtain the final set of line point points.

[0072] For each candidate line point in the second updated candidate line point set C2, an M*M region centered on that point is extracted from the original raster image as a Region of Interest (ROI). This ROI is then input into a pseudo-line head region recognition model. This model employs an existing deep learning artificial intelligence model, such as a convolutional neural network. This model can identify ROIs and determine whether they are pseudo-line head regions. The size of M can be customized as needed, for example, it could be 100*100.

[0073] Existing pseudo-thread end region identification models can be based on a ResNet-based convolutional neural network. This network takes an M*M region of interest as input and outputs whether it is a pseudo-thread end region. Alternatively, other classifiers such as MobileNet can also be used.

[0074] like Figure 5 As shown, when the identification result of a certain region of interest is a pseudo-line head region, the corresponding candidate line head points in the pseudo-line head region are removed. This process is repeated, and after the second updated candidate line head point set C2 is filtered by the pseudo-line head region identification model, the final candidate line head point set C3 can be obtained. At this point, each candidate line head point in the final candidate line head point set C3 is a true line head point, achieving fast and accurate detection of line head defects in the line drawing.

[0075] It is understandable that after completing step S160, a visual detection result or statistical report with annotation information can be generated based on the final set of line end points C3.

[0076] For example, the coordinates of all points in the final set of line points C3 can be read and displayed on the original line drawing using visualization techniques such as circles or squares based on the coordinates. This allows for quick modification of the line drawing by viewing the output visual markers, thereby effectively improving the quality of the line drawing.

[0077] Based on the above description, the detection method 100 according to the embodiment of this application implements a cascaded filtering architecture with a three-level verification mechanism, which automatically removes false line ends and solves the problem of low efficiency in manual detection.

[0078] According to the detection method 100 of the embodiments of this application, an efficient method for detecting line defects is proposed. For example, it can be used for the quality inspection of line drawings in coloring games (Paint by Number). It can be integrated into the game development process or design tools to achieve rapid optimization of line drawing quality and improve the visual quality and user experience of coloring games.

[0079] refer to Figure 6 A detection apparatus 200 for implementing the detection method 100 according to an embodiment of this application includes a processor 210 and a memory 220. The detection apparatus 200 may include one or more processors 210 and one or more memories 220. The memory 220 stores an executable program that is run by the processor 210. When the executable program is run by the processor 210, it causes the processor 210 to execute the detection method 100 described above according to an embodiment of this application.

[0080] The processor 210 may be a central processing unit (CPU) or other processing units with data processing capabilities and / or instruction execution capabilities.

[0081] The memory 220 may include one or more computer program products, which may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may include, for example, random access memory (RAM) and / or cache memory. The non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc. One or more computer program instructions may be stored on the computer-readable storage medium, and the processor 210 may execute the program instructions to implement the client functions (implemented by the processor) in the embodiments of this application described herein, and / or other desired functions. Various applications and various data may also be stored in the computer-readable storage medium, such as various data used and / or generated by the applications.

[0082] The detection device 200 may also include input and output devices, which are interconnected via a bus system and / or other forms of connection mechanisms. It should be noted that... Figure 6 The components and structure of the detection device 200 shown are merely exemplary and not limiting; the detection device 200 may also have other components and structures as needed.

[0083] The input device can be a device used by a user to input commands, and can include one or more of a keyboard, mouse, microphone, and touchscreen. Furthermore, the input device can also be any interface for receiving information.

[0084] The output device can output various information (e.g., images or sounds) to the outside (e.g., a user), and may include one or more of a display, speaker, etc. Furthermore, the output device can also be any other device with output functionality.

[0085] For example, the example detection device 200 for implementing the detection method 100 according to the embodiments of this application can be applied to terminal devices (such as mobile phones), tablet computers, laptop computers, ultra-mobile personal computers (UMPCs), handheld computers, netbooks, personal digital assistants (PDAs), wearable devices (such as smartwatches, smart glasses, or smart helmets), augmented reality (AR) devices, virtual reality (VR) devices, smart home devices, in-vehicle computers, and other electronic devices. The embodiments of this application do not impose any limitations on this.

[0086] Those skilled in the art can understand the specific operation of the detection device 200 for implementing the detection method 100 according to the embodiments of this application in conjunction with the content described above. For the sake of brevity, the specific details will not be repeated here, but only some main operations of the processor 210 will be described.

[0087] In one embodiment of this application, when the executable program is run by the processor 210, the processor 210 performs the following steps:

[0088] The target line drawing is converted into a raster image. The raster image is then converted into a binary skeleton image. Potential line endpoints are identified in the binary skeleton image, and an initial set of candidate line endpoints is created based on all potential line endpoints. The initial set of candidate line endpoints is traversed, and any potential line endpoint is selected as the center. Within a neighborhood window of a set size, the nearest intersection point and the two farthest foreground points to the selected potential line endpoint are obtained. Based on the vector angles between the intersection points and the lines connecting them to the selected potential line endpoint and the two foreground points, a first pseudo-line endpoint filtering is performed to obtain a first updated set of candidate line endpoints. Based on the first updated set of candidate line endpoints, a clustering algorithm is used for a second pseudo-line endpoint filtering to obtain a second updated set of candidate line endpoints. The second updated set of candidate line endpoints is traversed, and any candidate line endpoint is selected as the center. A corresponding region of a set size in the raster image is extracted as the region of interest. The region of interest is input into a pseudo-line endpoint region recognition model, and the final set of line endpoints is obtained based on the recognition results.

[0089] The above exemplarily illustrates a detection method 100 according to an embodiment of this application. The following, in conjunction with... Figure 7 The present application describes a detection system 300 provided in another aspect of its embodiments.

[0090] Reference Figure 7 This document describes an example detection system 300 for implementing the detection method of the embodiments of this application. The detection system 300 may include a grid image conversion module 310, a skeleton image conversion module 320, an initial set creation module 330, a first set acquisition module 340, a second set acquisition module 350, and a model recognition result module 360. Wherein:

[0091] The raster image module 310 is used to convert a target line drawing into a raster image.

[0092] The skeleton image conversion module 320 is used to convert the raster image into a binary skeleton image.

[0093] The initial set creation module 330 is used to: identify potential line end points in the binary skeleton graph, and create an initial set of candidate line end points based on all potential line end points.

[0094] The first set acquisition module 340 is used to: traverse the initial set of candidate line ends and select any potential line end point as the center, acquire the intersection point closest to the selected potential line end point and the two foreground points farthest from it within a neighborhood window of a set size; perform the first pseudo line end point filtering based on the vector angle between the intersection point and the line connecting the selected potential line end point and the two foreground points, and acquire the first updated set of candidate line ends.

[0095] The second set acquisition module 350 is used to: perform a second pseudo-line endpoint filtering based on the first updated line candidate point set using a clustering algorithm, and obtain the second updated line candidate point set.

[0096] The model recognition result module 360 ​​is used to: traverse the second updated candidate line point set and select any candidate line point as the center, extract the corresponding area of ​​a set size in the raster image as the region of interest, input the region of interest into the pseudo line point region recognition model, and obtain the final set of line point points based on the recognition result.

[0097] The detection system 300 proposed in this embodiment of the invention can quickly and accurately detect wire end defects.

[0098] Furthermore, according to embodiments of this application, this application also provides a storage medium on which a computer program is stored. When the computer program is run by a processor, it is used to execute corresponding steps of the detection method 100 of this application. The storage medium may, for example, include a memory card of a smartphone, a storage component of a tablet computer, a hard disk of a personal computer, a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a portable compact disc read-only memory (CD-ROM), a USB memory, or any combination of the above storage media. The computer-readable storage medium may be any combination of one or more computer-readable storage media.

[0099] Furthermore, according to embodiments of this application, this application also provides a computer program product, including computer instructions, which, when executed by a processor, implement the steps of the detection method of embodiments of this application.

[0100] Although exemplary embodiments have been described herein with reference to the accompanying drawings, it should be understood that the above exemplary embodiments are merely illustrative and are not intended to limit the scope of this application. Various changes and modifications can be made therein by those skilled in the art without departing from the scope and spirit of this application. All such changes and modifications are intended to be included within the scope of this application as claimed in the appended claims.

[0101] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0102] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed.

[0103] Furthermore, those skilled in the art will understand that although some embodiments described herein include certain features but not others included in other embodiments, combinations of features from different embodiments are intended to be within the scope of this application and form different embodiments. For example, in the claims, any one of the claimed embodiments can be used in any combination.

[0104] It should be noted that the above embodiments are illustrative of this application and not restrictive, and that those skilled in the art can devise alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses should not be construed as limiting the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. This application can be implemented by means of hardware comprising several different elements and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means may be embodied by the same item of hardware. The use of the words first, second, and third, etc., does not indicate any order. These words can be interpreted as names.

[0105] The above description is merely a specific embodiment or illustration of the embodiments of this application. The scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. The scope of protection of this application shall be determined by the scope of the claims.

Claims

1. A method for detecting line end defects in line drawings, characterized in that, The detection method includes: Convert the target line drawing into a raster image; The raster image is converted into a binary skeleton map; Identify potential line endpoints in the binarized skeleton graph and create an initial set of candidate line endpoints based on all potential line endpoints; Traverse the initial set of candidate line ends and select any potential line end point as the center. Obtain the nearest intersection point and the two farthest foreground points within a neighborhood window of a set size that are closest to the selected potential line end point. Calculate the first cosine of the first angle between the line connecting the relatively closer foreground point and the intersection point among the two farthest foreground points and the line connecting the selected potential line end point and the intersection point. Calculate the second cosine of the second angle between the lines connecting the two farthest foreground points and the intersection point respectively. When the sum of the first and second cosine values ​​is less than a set value, the selected potential line end point is removed as a pseudo line end point, thus achieving the first pseudo line end point filtering and obtaining the first updated set of candidate line ends. Based on the first updated candidate point set, a clustering algorithm is used to perform a second pseudo-endpoint filtering to obtain the second updated candidate point set. Traverse the second updated candidate line point set and select any candidate line point as the center. Extract the corresponding region of a set size in the raster image as the region of interest. Input the region of interest into the pseudo line point region recognition model and obtain the final set of line point points based on the recognition results.

2. The detection method according to claim 1, characterized in that, The identification of potential line endpoints in the binarized skeleton image specifically includes: Based on the set convolutional detection kernel and the corresponding set convolutional value, the eight-neighbor convolution algorithm is used to obtain the full-image convolutional result of the binary skeleton graph; if the convolutional result matches the set convolutional value, the corresponding point is a potential line endpoint.

3. The detection method according to claim 2, characterized in that, The defined convolutional detection kernel and corresponding defined convolutional value are specifically represented as follows: Defined convolutional detection kernel When the corresponding convolution value is set to 11; or The pixels of the binarized skeleton map convolved with the set convolutional detection kernel K Then it is necessary to ensure the pixel It is a foreground pixel, and among the remaining 8 pixels, exactly one is a foreground pixel.

4. The detection method according to claim 1, characterized in that, The second filtering of pseudo-line points based on the first updated candidate line point set using a clustering algorithm specifically refers to: Select any candidate point in the first set of candidate points for updating the line as the center, and add the density-reachable points based on the set neighborhood radius of the cluster to obtain the corresponding dense point group; If the total number of points in a dense point group exceeds a set threshold, all points in the dense point group will be removed as pseudo-line start points.

5. The detection method according to claim 1, characterized in that, The step of inputting the region of interest into the pseudo-line end region recognition model and obtaining the final set of line end points based on the recognition results specifically refers to: The pseudo-line head region identification model identifies the region of interest and outputs the identification result of whether the region of interest is a pseudo-line head region; When the identification result is a pseudo-line head region, remove the line head candidate points corresponding to the region of interest from the second updated line head candidate point set; otherwise, retain them. Repeat the above steps to obtain the final set of line start points.

6. The detection method according to claim 1, characterized in that, The detection method further includes: Obtain the coordinates of each linehead in the final set of linehead points, and perform visual annotation on the target line drawing based on the coordinates of the linehead points, including marking the corresponding points in the target line drawing with circles or squares.

7. The detection method according to claim 1, characterized in that, The process of converting the raster image into a binary skeleton image specifically refers to: Convert a raster image to a grayscale image; The black and white colors in the grayscale image are swapped, and a thinning algorithm is used for iterative processing to generate a binary skeleton image.

8. A device for detecting line end defects in line drawings, characterized in that, The detection device includes: Memory is used to store executable instructions for a computer; A processor, when executing computer-executable instructions stored in the memory, implements the detection method according to any one of claims 1 to 7.

9. A storage medium storing computer instructions, wherein, The computer instructions are used to cause the computer to perform the detection method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Method and device for judging broken line, electronic equipment and storage medium

    CN113610761A

  • Chamfer defect detection method, device and equipment and storage medium

    CN119648620A