Line chart coloring method and device, equipment, storage medium and program product
By identifying and connecting breakpoints and their connection points in the line strip diagram, forming target lines and coloring local areas, the problem of low line gap closure efficiency in the prior art is solved, and more efficient image processing and user experience are achieved.
Patent Information
- Application Number
- CN202510322960.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-18
- Publication Date
- 2025-06-13
AI Technical Summary
The prior art has low efficiency when the gaps of lines in closed line drawings, especially when facing pictures with larger resolution or large numbers of pictures, the data processing order is too large and the calculation is slow.
By determining a first closed area including a trigger position in the line strip diagram, the line profile associated with the area is extracted, and the breakpoint and its connection point are identified and connected, a target line is formed, and the second closed area is determined based on the target line and the trigger position to color.
The gap closure efficiency caused by line break points in line drawing is improved, the data processing level is reduced, the image processing speed and processing efficiency is improved, and the coloring efficiency and user experience of line drawing is improved.
Smart Images

Figure CN120147461A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular, to a method, apparatus, electronic device, computer-readable storage medium, and computer program product for coloring line drawings. Background Art
[0002] During the process of drawing a line drawing, gaps (situations where two lines should be connected but are not) always occur. As a result, when coloring the line drawing, the closed areas that need to be colored cannot be clearly determined, leading to the coloring operation overflowing into areas where coloring is not desired, presenting a risk of color bleeding or contamination. Therefore, before coloring the line drawing, it is necessary to close the gaps. In this regard, most related technologies refine the image, extract the skeleton from the refined image, and then close the gaps. However, this method requires traversing all points in the image and extracting the skeleton, resulting in low efficiency. Especially when facing pictures with large resolutions or a large number of pictures, the magnitude of data processing is too large and the calculation is very slow. Based on this, the closing efficiency of closing the gaps in the lines of the line drawing is low in related technologies. Summary of the Invention
[0003] Embodiments of the present application provide a method, apparatus, electronic device, computer-readable storage medium, and computer program product for coloring line drawings, which can improve the closing efficiency when closing the gaps caused by breakpoints on the lines in the line drawings.
[0004] The technical solution of the embodiments of the present application is implemented as follows:
[0005] Embodiments of the present application provide a method for coloring a line drawing, including:
[0006] In response to a coloring request for the line drawing, based on the trigger position in the line drawing in the coloring request, determine a first closed area in the line drawing that includes the trigger position;
[0007] In the line drawing, determine a plurality of lines associated with the first closed area, and extract the contours of each of the lines;
[0008] For the contour of each line, when there is a breakpoint on the contour, determine the connection point of the breakpoint in the first closed area, and connect the breakpoint and the connection point to obtain a target line;
[0009] Based on the target line and the trigger position, determine a second closed area in the first closed area that includes the trigger position, and color the second closed area.
[0010] Embodiments of the present application provide a device for coloring a line drawing, including:
[0011] A first determination module, configured to, in response to a coloring request for a line graph, determine a first closed area including the trigger position in the line graph based on the trigger position of the coloring request in the line graph;
[0012] A second determination module, configured to determine a plurality of lines associated with the first closed area in the line graph, and extract the contours of each of the lines;
[0013] A connection module, configured to, for the contour of each of the lines, when there is a break point on the contour, determine a connection point of the break point in the first closed area, and connect the break point and the connection point to obtain a target line;
[0014] A coloring module, configured to determine a second closed area including the trigger position in the first closed area based on the target line and the trigger position, and color the second closed area.
[0015] In the above solution, the second determination module is further configured to determine a circumscribed rectangle of the first closed area in the line graph; and determine the plurality of lines included in the circumscribed rectangle as the plurality of lines associated with the first closed area.
[0016] In the above solution, the second determination module is further configured to determine a circumscribed rectangle of the first closed area in the line graph; perform binarization processing on the circumscribed rectangle to obtain a binarized rectangle of the circumscribed rectangle; extract binarized lines in the binarized rectangle, and determine the extracted binarized lines as the contours of each of the lines.
[0017] In the above solution, the device further includes a traversal module, configured to determine a circumscribed rectangle of the first closed area in the line graph, and traverse each of the contours; during the traversal, detect the traversed contour based on the circumscribed rectangle to obtain a detection result, where the detection result is used to indicate whether the contour is at the edge of the circumscribed rectangle; based on each of the detection results, filter out the contours at the edge of the circumscribed rectangle from the plurality of contours to obtain target contours; the connection module is further configured to, for each of the target contours, when there is a break point on the target contour, determine a connection point of the break point in the first closed area.
[0018] In the above solution, the first determination module is further configured to perform color filling on the closed area where the trigger position is located in the line graph to obtain a filled closed area; and determine the filled closed area as the first closed area.
[0019] In the above solution, the device further includes an acquisition module, which is configured to acquire a first distance between the break point and the connection point; the connection module is further configured to determine that there is a gap between the break point and the connection point when the first distance is less than or equal to a first distance threshold, and connect the break point and the connection point to obtain a target line for closing the gap.
[0020] In the above solution, the device further includes a threshold setting module, which is configured to display a setting interface for the distance threshold; in response to a threshold setting operation performed in the setting interface, display the set distance threshold; in response to a determination instruction, determine the set distance threshold as the first distance threshold, and the first distance threshold is used to determine whether there is a gap between the break point and the connection point.
[0021] In the above solution, the device further includes a search module, which is configured to determine a plurality of points on each of the contours, and for each of the points, perform the following processing: determine a preset distance condition corresponding to the point, and search on the contour for a first associated point and a second associated point that satisfy the preset distance condition; based on the first associated point and the second associated point, determine whether the point is a break point on the contour.
[0022] In the above solution, the search module is further configured to connect the point and the first associated point to obtain a first line segment, and connect the point and the second associated point to obtain a second line segment; construct a target angle with the point as the vertex and the first line segment and the second line segment as the sides; when the angle of the target angle is less than or equal to an angle threshold, acquire a second distance between the two target associated points; when the second distance is less than or equal to a second distance threshold, determine the point as a break point on the contour.
[0023] In the above solution, the connection module is further configured to acquire a plurality of third associated points of the break point from the plurality of points included in the contour, where the distance between the third associated point and the break point is less than or equal to a third distance threshold; perform linear fitting on the plurality of third associated points to obtain a fitting line; based on the fitting line, determine the connection point of the break point.
[0024] In the above solution, the connection module is further configured to determine at least one intersection point between the fitting line and the line in the line graph; select, from the at least one intersection point, the intersection point closest to the break point as the connection point.
[0025] In the above solution, the coloring module is further configured to determine a closed line formed by the target lines and surrounding the trigger position, and in the first closed area, use the area surrounded by the closed line as the second closed area.
[0026] In the above solution, the coloring module is further configured to determine a target color corresponding to the coloring request, and fill the area enclosed by the closed line with the target color; obtain the current color of the closed line, and when the current color is inconsistent with the target color, adjust the closed line from the current color to the target color.
[0027] An embodiment of the present application provides an electronic device, including:
[0028] A memory for storing computer-executable instructions or computer programs;
[0029] A processor, when executing the computer-executable instructions or computer programs stored in the memory, implements the coloring method of the line drawing provided by the embodiment of the present application.
[0030] An embodiment of the present application provides a computer-readable storage medium storing computer-executable instructions or computer programs, which are used to cause a processor to implement the coloring method of the line drawing provided by the embodiment of the present application when executed.
[0031] An embodiment of the present application provides a computer program product, which includes computer-executable instructions or computer programs. The computer-executable instructions or computer programs are stored in a computer-readable storage medium. The processor of the electronic device reads the computer-executable instructions or computer programs from the computer-readable storage medium, and the processor executes the computer-executable instructions or computer programs, so that the electronic device executes the coloring method of the line drawing provided by the embodiment of the present application.
[0032] The embodiments of the present application have the following beneficial effects:
[0033] When receiving a coloring request for a line graph, based on the trigger position of the coloring request, determine a first closed area including the trigger position in the line graph, and extract the outlines of each line associated with the first closed area in the line graph. Thus, when there are breakpoints on the outline and connection points of the breakpoints are determined in the first closed area, connect the breakpoints and the connection points, and based on the obtained target line and the trigger position, determine a second closed area including the trigger position in the first closed area, and then color the second closed area. In this way, based on the first closed area in the line graph, analyze to obtain the breakpoints on the lines in the line graph and the corresponding connection points, so as to connect the breakpoints and the corresponding connection points. In this way, compared with the solution in the related art that needs to traverse all points in the line graph to extract the skeleton to achieve gap closure, by analyzing the local area of the line graph, obtain the gaps caused by the breakpoints on the lines in the line graph, so as to close the gaps, reduce the data processing level, improve the image processing speed and processing efficiency, that is, improve the closing efficiency when closing the gaps caused by the breakpoints on the lines in the line graph, thereby improving the coloring efficiency of the line graph. At the same time, it also improves the user experience and reduces the user's processing waiting time. Description of the Drawings
[0034] Figure 1 is a schematic structural diagram of a line graph coloring system 100 provided by an embodiment of the present application;
[0035] Figure 2 is a schematic structural diagram of an electronic device provided by an embodiment of the present application;
[0036] Figure 3 is a schematic flowchart of a line graph coloring method provided by an embodiment of the present application;
[0037] Figure 4 is a schematic diagram of a line graph provided by an embodiment of the present application;
[0038] Figure 5 is a schematic diagram of the determination process of the first closed area provided by an embodiment of the present application;
[0039] Figure 6 is a schematic diagram of multiple lines associated with the first closed area provided by an embodiment of the present application;
[0040] Figure 7 is a schematic diagram of a circumscribed rectangle provided by an embodiment of the present application;
[0041] Figure 8 is a schematic diagram of a binarized rectangle and binarized lines provided by an embodiment of the present application;
[0042] Figure 9 is a schematic diagram of the edge of a circumscribed rectangle provided by an embodiment of the present application;
[0043] Figure 10 It is a schematic flowchart for determining whether there is a breakpoint on the contour provided by an embodiment of the present application;
[0044] Figure 11 It is a schematic diagram of the determination process of the first associated point and the second associated point provided by an embodiment of the present application;
[0045] Figure 12 It is a schematic diagram showing that the angle of the target angle is greater than the angle threshold provided by an embodiment of the present application;
[0046] Figure 13 It is a schematic diagram showing that the second distance is greater than the second distance threshold provided by an embodiment of the present application;
[0047] Figure 14 It is a schematic diagram of a breakpoint provided by an embodiment of the present application;
[0048] Figure 15 It is a schematic diagram of a connection point provided by an embodiment of the present application;
[0049] Figure 16 It is a schematic diagram of two line interruption methods provided by an embodiment of the present application;
[0050] Figure 17 It is a schematic diagram of the second closed area provided by an embodiment of the present application;
[0051] Figure 18 It is a schematic diagram of the second closed area provided by an embodiment of the present application;
[0052] Figure 19 It is a schematic diagram of the colored second closed area provided by an embodiment of the present application;
[0053] Figure 20 It is a schematic flowchart of the coloring method for a line drawing provided by an embodiment of the present application;
[0054] Figure 21 It is a schematic diagram of the setting interface for the distance threshold provided by an embodiment of the present application;
[0055] Figure 22 It is a schematic flowchart of the coloring method for a line drawing provided by an embodiment of the present application. Detailed implementation manners
[0056] In order to make the objectives, technical solutions and advantages of the present application clearer, the present application will be further described in detail below with reference to the accompanying drawings. The described embodiments should not be regarded as limitations on the present application. All other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the scope of protection of the present application.
[0057] In the following description, reference is made to "some embodiments", which describe a subset of all possible embodiments. However, it can be understood that "some embodiments" can be the same subset or different subsets of all possible embodiments, and can be combined with each other without conflict.
[0058] In the following description, the terms "first / second / third" are only used to distinguish similar objects and do not represent a specific order for the objects. It can be understood that "first / second / third" can be interchanged in a specific order or sequence when allowed, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.
[0059] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those of ordinary skill in the technical field to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0060] Before further elaborating on the embodiments of this application, the nouns and terms involved in the embodiments of this application are described. The nouns and terms involved in the embodiments of this application are subject to the following explanations.
[0061] 1) Responsive to, used to represent the conditions or states on which the operations performed depend. When the dependent conditions or states are met, one or more operations performed can be real-time or can have a set delay; without special instructions, there is no restriction on the execution order of multiple operations performed.
[0062] 2) Client, also known as the user side, refers to a program that provides local services for users corresponding to the server. Except for some applications that can only run locally, it is generally installed on the terminal and needs to cooperate with the server to run, that is, there needs to be a corresponding server and service program in the network to provide corresponding services. In this way, a specific communication connection needs to be established between the client side and the server side to ensure the normal operation of the application program, such as a virtual scene client (such as a game client), a video client.
[0063] 3) Artificial Intelligence (AI), is to use a digital computer or a machine controlled by a digital computer to simulate, extend and expand human intelligence, a theory, method, technology and application system that perceives the environment, acquires knowledge and uses knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology of computer science. It attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a way similar to human intelligence. Artificial intelligence also studies the design principles and implementation methods of various intelligent machines, so that the machines have the functions of perception, reasoning and decision-making.
[0064] 4) A line drawing is an image mainly composed of lines. It depicts the outline, structure, or dynamics of an object through changes in the thickness, length, curvature, and density of the lines. In practical applications, a line drawing at least includes a line draft, a structure diagram, or a technical drawing, etc.
[0065] 5) A line draft is a sketch or drawing mainly composed of lines, usually used to depict the outline and structure of an object, without relying on shadows, textures, or colors to represent the three-dimensional sense or texture of the object.
[0066] In actual implementation, the method for coloring a line drawing provided by the embodiments of the present application can be applied to various fields or scenarios, such as an animation production scenario, an illustration creation scenario, and a game development scenario, etc. The following are examples for illustration.
[0067] 1) Animation production scenario. For example, when the terminal device receives a coloring operation triggered by the user for an animation character in an animation frame, or a coloring operation for an animation scene or background in an animation frame, it sends a coloring request for the animation frame to the server. When there is a line gap in the closed area surrounding the trigger position of the coloring operation, the server closes the line gap to form a new closed area, thereby coloring the new closed area, and then returns the colored animation frame to the terminal device for the user to draw.
[0068] 2) Illustration creation scenario. For example, when the terminal device receives a coloring operation for an illustration in a children's book, a popular science book, or an advertising poster, it sends a coloring request for the illustration to the server. When there is a line gap in the closed area surrounding the trigger position of the coloring operation, the server closes the line gap to form a new closed area, thereby coloring the new closed area, and then returns the colored illustration to the terminal device for the user to perform secondary editing.
[0069] 3) Game development scenario. For example, when the terminal device receives a coloring operation for a character model, an environment, and props, etc. in a game line draft, it sends a coloring request for the game line draft to the server. When there is a line gap in the closed area surrounding the trigger position of the coloring operation, the server closes the line gap to form a new closed area, thereby coloring the new closed area, and then returns the colored game line draft to the terminal device for the user to draw again.
[0070] See Figure 1 , Figure 1 is a schematic architecture diagram of the line drawing coloring system 100 provided by the embodiments of the present application. The terminal 400 is connected to the server 200 through the network 300. Among them, the network 300 can be a wide area network or a local area network, or a combination of the two, and uses a wireless or wired link to implement data transmission.
[0071] Among them, the terminal 400 is used to send a coloring request for the line graph to the server 200;
[0072] The server 200 is used to receive a coloring request for the line graph, and in response to the coloring request for the line graph, based on the trigger position in the line graph in the coloring request, determine a first closed area including the trigger position in the line graph; in the line graph, determine a plurality of lines associated with the first closed area, and extract the outlines of each line; for the outline of each line, when there is a break point on the outline, determine the connection point of the break point in the first closed area, and connect the break point and the connection point to obtain a target line; based on the target line and the trigger position, determine a second closed area including the trigger position in the first closed area, and color the second closed area.
[0073] In this way, based on the first closed area in the line graph, the break points on the lines in the line graph and the corresponding connection points are analyzed, so as to connect the break points and the corresponding connection points. In this way, compared with the solution in the related art that needs to traverse all points in the line graph to extract the skeleton to realize gap closing, by analyzing the local area of the line graph, the gap caused by the break points on the lines in the line graph is obtained, so as to close the gap, reduce the data processing level, improve the image processing speed and processing efficiency, that is, improve the closing efficiency when closing the gap caused by the break points on the lines in the line graph, thereby improving the coloring efficiency of the line graph. At the same time, the user experience is also improved, and the user processing waiting time is reduced.
[0074] In some embodiments, the server 200 may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs, Content Deliver Network), and big data and artificial intelligence platforms. The terminal 400 may be a smart phone, a tablet computer, a notebook computer, a desktop computer, a set-top box, a smart voice interaction device, a smart home appliance, a virtual reality device, a vehicle-mounted terminal, an aircraft, a portable music player, a personal digital assistant, a dedicated messaging device, a portable game device, a smart speaker, a smart watch, etc., but is not limited thereto. The terminal and the server may be directly or indirectly connected through wired or wireless communication methods, and no limitation is made in the embodiments of the present application.
[0075] Next, the electronic device for implementing the coloring method of the line graph provided in the embodiments of the present application will be described. Refer to Figure 2 , Figure 2FIG. 0 is a schematic structural diagram of an electronic device provided by an embodiment of the present application. The electronic device can be a server or a terminal. Taking the server shown in Figure 1 as an example, Figure 2 the electronic device shown in FIG. 4 includes at least one processor 410, a memory 450, at least one network interface 420, and a user interface 430. Each component in the electronic device is coupled together through a bus system 440. It can be understood that the bus system 440 is used to realize the connection and communication between these components. In addition to the data bus, the bus system 440 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clarity, in Figure 2 all kinds of buses are labeled as the bus system 440.
[0076] The processor 410 can be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP, Digital Signal Processor), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor can be a microprocessor or any conventional processor, etc.
[0077] The user interface 430 includes one or more output devices 431 capable of displaying media content, including one or more speakers and / or one or more visual display screens. The user interface 430 also includes one or more input devices 432, including user interface components that help users input, such as keyboards, mice, microphones, touch screen displays, cameras, other input buttons, and controls.
[0078] The memory 450 can be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid-state memories, hard disk drives, optical disc drives, etc. The memory 450 optionally includes one or more storage devices that are physically located away from the processor 410.
[0079] The memory 450 includes volatile memory or non-volatile memory, and can also include both volatile and non-volatile memory. The non-volatile memory can be a read-only memory (ROM, Read Only Memory), and the volatile memory can be a random access memory (RAM, Random Access Memory). The memory 450 described in the embodiments of the present application is intended to include any suitable type of memory.
[0080] In some embodiments, the memory 450 is capable of storing data to support various operations. Examples of these data include programs, modules, and data structures, or subsets or supersets thereof, which are described below by way of example.
[0081] The operating system 451 includes system programs for processing various basic system services and performing hardware-related tasks, such as the framework layer, the core library layer, the driver layer, etc., for implementing various basic services and processing hardware-based tasks.
[0082] The network communication module 452 is used to reach other electronic devices via one or more (wired or wireless) network interfaces 420. Exemplary network interfaces 420 include: Bluetooth, Wireless Fidelity (WiFi), and Universal Serial Bus (USB), etc.
[0083] The presentation module 453 is used to enable the display of information (such as a user interface for operating peripheral devices and displaying content and information) via one or more output devices 431 associated with the user interface 430 (such as a display screen, a speaker, etc.).
[0084] The input processing module 454 is used to detect and translate one or more user inputs or interactions from one of one or more input devices 432.
[0085] In some embodiments, the device provided by the embodiments of the present application can be implemented in software. Figure 2 Shown is a coloring device 455 for line drawings stored in the memory 450, which can be software in the form of a program and a plug-in, etc., including the following software modules: a first determination module 4551, a second determination module 4552, a connection module 4553, and a coloring module 4554. These modules are logical, so they can be combined arbitrarily or further split according to the functions to be implemented. The functions of each module will be described below.
[0086] In other embodiments, the device provided by the embodiments of the present application can be implemented in hardware. As an example, the coloring device for line drawings provided by the embodiments of the present application can be a processor in the form of a hardware decoding processor, which is programmed to execute the coloring method for line drawings provided by the embodiments of the present application. For example, a processor in the form of a hardware decoding processor can adopt one or more Application Specific Integrated Circuits (ASICs), DSPs, Programmable Logic Devices (PLDs), Complex Programmable Logic Devices (CPLDs), Field-Programmable Gate Arrays (FPGAs), or other electronic components.
[0087] In some embodiments, a terminal or a server may implement the method for coloring a line drawing provided in the embodiments of the present application by running a computer program. For example, the computer program may be a native program or a software module in an operating system; it may be a local (Native) application (APP, Application), that is, a local client, that is, a program that needs to be installed in the operating system to run, such as an instant messaging APP or a web browser APP; it may also be a small program, that is, a program that only needs to be downloaded to a browser environment to run; it may also be a small program that can be embedded in any APP. In short, the above computer program may be any form of client, module or plug-in.
[0088] Based on the above description of the system for coloring a line drawing and the electronic device provided in the embodiments of the present application, the method for coloring a line drawing provided in the embodiments of the present application will be described below. In actual implementation, the method for coloring a line drawing provided in the embodiments of the present application may be implemented independently by a terminal or a server, or implemented jointly by a terminal and a server, taking Figure 1 the server 200 in Figure 3 , Figure 3 as an example to separately execute the method for coloring a line drawing provided in the embodiments of the present application. Refer to Figure 3 for illustration.
[0089] Step 101, the server, in response to a coloring request for a line drawing, determines a first closed area including the trigger position in the line drawing based on the trigger position of the coloring request in the line drawing.
[0090] In actual implementation, the coloring request for the line drawing is sent by a terminal. Specifically, the terminal displays the line drawing, and then, in response to a coloring operation on the line drawing, generates a coloring request for the line drawing and sends the coloring request for the line drawing to the server; thus, after receiving the coloring request for the line drawing, the server, in response to the coloring request for the line drawing, identifies the trigger position of the coloring request, obtains the trigger position of the coloring request, and then determines a first closed area including the trigger position in the line drawing based on the trigger position of the coloring request in the line drawing.
[0091] It should be noted that a line drawing is an image mainly composed of lines, and it depicts the outline, structure or dynamics of an object through changes in the thickness, length, curvature, density, etc. of the lines; among them, the line drawing here at least includes a line draft, a structure diagram or a technical drawing, etc., and a line draft is a sketch or drawing mainly composed of lines, usually used to depict the outline and structure of an object, and does not rely on shadows, textures or colors to express the three-dimensional sense or texture of the object. Exemplarily, refer to Figure 4 ,Figure 4 is a schematic diagram of a line graph provided by an embodiment of the present application. Based on Figure 4 , Figure 4 in which the figure formed by the black lines is a line graph.
[0092] In some embodiments, the process of determining the first closed area including the trigger position in the line graph based on the trigger position of the coloring request in the line graph may be to fill the color of the closed area where the trigger position is located in the line graph to obtain the filled closed area; and determine the filled closed area as the first closed area.
[0093] It should be noted that after receiving the coloring request for the line graph, based on the trigger position, the area surrounding the trigger position is detected to obtain the closed area where the trigger position is located, and then the color of the closed area where the trigger position is located is filled to obtain the filled closed area, so as to determine the filled closed area as the first closed area.
[0094] Exemplarily, referring to Figure 5 , Figure 5 is a schematic diagram of the process of determining the first closed area provided by an embodiment of the present application. Based on Figure 5 , the circular position indicated by 501 is the trigger position of the coloring request, and in the area indicated by the dashed box 502, the area surrounded by the lines corresponding to the multiple black solid dots is the first closed area.
[0095] In this way, by filling the color of the area where the trigger position of the coloring request is located to determine the closed area where the trigger position is located, the boundary detection can be performed by using the coloring operation, so as to find and color along the edge of the closed area, which is convenient for determining the closed area where the trigger position is located, that is, the determination efficiency of the closed area where the trigger position is located is improved.
[0096] Step 102: In the line graph, determine multiple lines associated with the first closed area and extract the outlines of each line.
[0097] In actual implementation, since the main elements in the line graph are lines, the multiple lines associated with the first closed area may only include the lines within the first closed area, or include the lines within the first closed area and the lines outside the first closed area; based on this, there are multiple ways to determine the multiple lines associated with the first closed area in the line graph, so that different multiple lines associated with the first closed area are obtained based on different determination methods. Next, taking two of these methods as examples, the process of determining the multiple lines associated with the first closed area in the line graph will be described.
[0098] In some embodiments, in a line drawing, the process of determining a plurality of lines associated with a first closed area may be to directly extract a plurality of lines included in the first closed area in the line drawing as the plurality of lines associated with the first closed area.
[0099] It should be noted that the extracted first closed area includes a plurality of lines, that is, lines inside the first closed area; for example, see Figure 6 , Figure 6 is a schematic diagram of multiple lines associated with a first closed area provided in an embodiment of the present application, based on Figure 6 , Figure 6 The area surrounded by the lines corresponding to the multiple black solid dots is the first closed area, and the lines indicated by 601, 602 and 603 are all lines in the first closed area.
[0100] In other embodiments, the process of determining the multiple lines associated with the first closed area in the line drawing may be, in the line drawing, determining the circumscribed rectangle of the first closed area; and determining the multiple lines included in the circumscribed rectangle as the multiple lines associated with the first closed area.
[0101] It should be noted that the circumscribed rectangle of a closed area in a line drawing refers to a minimum rectangle that can enclose the closed area, which completely encloses all points in the closed area; for example, see Figure 7 , Figure 7 is a schematic diagram of a circumscribed rectangle provided in an embodiment of the present application, based on Figure 7 , Figure 7 The area indicated by 706 and surrounded by the lines corresponding to the multiple black solid points is the first closed area, and the rectangle indicated by the black line frame 705 is the circumscribed rectangle of the first closed area indicated by 706 .
[0102] After determining the circumscribed rectangle, the multiple lines included in the extracted circumscribed rectangle are determined as the multiple lines associated with the first closed area. Here, the multiple lines included in the extracted circumscribed rectangle, that is, the lines inside the circumscribed rectangle, include the lines in the first closed area and the lines outside the first closed area. For example, continue to refer to Figure 7 ,based on Figure 7 , the multiple lines in the circumscribed rectangle include lines indicated by 701, 702 and 703, and lines indicated by 704 located outside the first closed area, wherein the lines indicated by 701, 702 and 703, and the line indicated by 704 are used as examples for illustration, and it does not mean that the multiple lines in the circumscribed rectangle only include the lines indicated by 701, 702 and 703, and the line indicated by 704.
[0103] It should be noted that after determining the circumscribed rectangle, based on the circumscribed rectangle, the line graph is cropped to obtain the circumscribed rectangle image in the line graph, so that the multiple lines included in the circumscribed rectangle are determined as the multiple lines associated with the first closed region, that is, the multiple lines included in the circumscribed rectangle image are determined as the multiple lines associated with the first closed region.
[0104] In this way, by determining the circumscribed rectangle of the first closed region, multiple lines are determined based on the circumscribed rectangle, that is, processing is performed based on the circumscribed rectangle. In this way, since the size of the circumscribed rectangle is definitely smaller than the size of the line graph, not only can the image processing task be simplified, the amount of image processing data be reduced, and the image processing efficiency be improved, but also the analysis can focus on the first closed region itself while ignoring other irrelevant background information, thereby improving the accuracy of the image processing result, that is, improving the accuracy of the extracted lines.
[0105] In actual implementation, after determining the multiple lines associated with the first closed region, the outlines of each line can be extracted. Here, the process of extracting the outlines of each line can be: in the line graph, determine the circumscribed rectangle of the first closed region; perform binarization processing on the circumscribed rectangle to obtain the binarized rectangle of the circumscribed rectangle; extract the binarized lines in the binarized rectangle, and determine the extracted binarized lines as the outlines of each line.
[0106] It should be noted that the outline of a line, i.e., the contour line of the line, is equivalent to the boundary line of the line and is used to display the boundary information of the line; in a line graph, the process of determining the circumscribed rectangle of the first closed region is as described above, where the circumscribed rectangle here refers to the smallest rectangle that can enclose the first closed region; and binarization refers to the process of converting an image or data into one that contains only two values (usually 0 and 1, or black and white). In the process of image processing, binarization processing is often used to simplify the image and highlight key information. The process of binarizing the circumscribed rectangle is to convert the pixels in the circumscribed rectangle into black or white, so that the binarized rectangle becomes an image including black and white, that is, the binarized rectangle is a digital image composed of pixels, where each pixel has only two possible states, namely black or white; among them, the process of converting the pixels in the circumscribed rectangle into black or white specifically includes performing grayscale processing on the circumscribed rectangle to obtain a grayscale rectangle; obtaining a binarization threshold, and then comparing the grayscale value of each pixel point in the grayscale rectangle with the binarization threshold respectively, and based on the comparison result, setting the pixel value of the corresponding pixel point to 0 or 255, that is, converting the color of the pixel point into black or white; here, it can be preset that when the grayscale value is greater than or equal to the binarization threshold, the color of the pixel point is converted into black, or when the grayscale value is less than the binarization threshold, the color of the pixel point is converted into white, or when the grayscale value is greater than or equal to the binarization threshold, the color of the pixel point is converted into white, or when the grayscale value is less than the binarization threshold, the color of the pixel point is converted into black. In this regard, the embodiments of the present application do not make any limitations.
[0107] It should be noted that the binarization threshold can be preset or calculated according to the Otsu algorithm. In this regard, the embodiments of the present application do not make any limitations.
[0108] In actual implementation, if there is a color change in the grayscale rectangle, such as the color of the line itself is different from the color of the area where the line is located, in this way, by binarizing the grayscale rectangle, the contour line of the line can be obtained, that is, the line formed by the pixel points at the position where the line contacts the area where the line is located (that is, the boundary position of the line), that is, the binarized line described above. At the same time, since each line has a certain width, there are two positions where the line contacts the area where the line is located (that is, the left side and the right side of the line). Therefore, for a line, there are two contour lines, and the distance between the two parallel contour lines is the width of the line wrapped by the two contour lines.
[0109] Based on this, the binarized line here is the line formed by the pixel points used to divide or distinguish the line from the area where the line is located in the binarized rectangle, that is, the line formed by the pixel points used to wrap the line in the corresponding binarized rectangle.
[0110] Exemplarily, refer to Figure 8, Figure 8 is a schematic diagram of a binarized rectangle and binarized lines provided by an embodiment of the present application. Based on Figure 8 , Figure 8 in Figure 8 , what a indicates is the circumscribed rectangle, and what b indicates is the binarized rectangle corresponding to the circumscribed rectangle; among them, taking the black line indicated by 801 in a as an example, after binarizing the circumscribed rectangle indicated by a to obtain the binarized rectangle indicated by b, the white line indicated by 802 in the binarized rectangle indicated by b is the outline of the black line indicated by 801 in a.
[0111] In this way, by binarizing the circumscribed rectangle of the closed area, the outline of the lines included in the circumscribed rectangle is obtained. In this way, on the premise of ensuring the image information, the image is simplified through binarization processing. Since the binarization processing converts the image into a simplified representation containing only two colors, black and white, the image is simplified on the premise of ensuring the image information, thereby simplifying the subsequent image processing process; at the same time, through the binarization processing, the line boundaries inside the circumscribed rectangle can be clearly extracted, which is convenient for further analyzing and identifying the shape of the lines in the image, thereby improving the extraction efficiency and accuracy of the outline of the lines.
[0112] In some embodiments, after extracting the outlines of each line, it is also possible to determine the circumscribed rectangle of the first closed area in the line graph and traverse each outline; during the traversal process, based on the circumscribed rectangle, the traversed outline is detected to obtain a detection result, and the detection result is used to indicate whether the outline is at the edge of the circumscribed rectangle; based on each detection result, the outlines at the edge of the circumscribed rectangle are filtered out from multiple outlines to obtain the target outline; thus, for the outlines of each line, when there is a breakpoint on the outline, the process of determining the connection point of the breakpoint in the first closed area can be, for each target outline, when there is a breakpoint on the target outline, the connection point of the breakpoint is determined in the first closed area.
[0113] It should be noted that the process of detecting the traversed outline based on the circumscribed rectangle to obtain the detection result can be, first, horizontal convolution and vertical convolution are respectively performed on the grayscale rectangle obtained by performing grayscale processing on the circumscribed rectangle to obtain the brightness gradients of the grayscale rectangle in the horizontal direction and the vertical direction, that is, the horizontal gradient and the vertical gradient. Specifically, two convolution kernels, such as a 3x3 convolution kernel, are obtained and used to detect the edges of the circumscribed rectangle in the horizontal direction and the vertical direction respectively. Then, based on these two convolution kernels, the grayscale rectangle is convolved respectively to obtain the brightness gradients of the grayscale rectangle in the horizontal direction and the vertical direction, that is, based on the horizontal convolution kernel and the vertical convolution kernel, that is, the grayscale rectangle is convolved to obtain the horizontal gradient and the vertical gradient; then, based on the horizontal gradient and the vertical gradient, the traversed outline is detected to obtain the detection result.
[0114] In actual implementation, the process of performing convolution processing on a grayscale rectangle based on a horizontal convolution kernel and a vertical convolution kernel to obtain a horizontal gradient and a vertical gradient is as follows:
[0115] I x = *G x ……Formula (1);
[0116] I y = *G y ……Formula (2);
[0117] Among them, I x in Formula (1) is the horizontal gradient, G x is the convolution kernel used to detect the edges in the horizontal direction, I y in Formula (2) is the vertical gradient, G y is the convolution kernel used to detect the edges in the vertical direction, and I is the grayscale rectangle.
[0118] It should be noted that for performing convolution processing on a grayscale rectangle based on a horizontal convolution kernel and a vertical convolution kernel to obtain a horizontal gradient and a vertical gradient, the horizontal gradient and the vertical gradient of each pixel point in the grayscale rectangle are obtained.
[0119] Therefore, the process of detecting the traversed contour based on the horizontal gradient and the vertical gradient to obtain a detection result is also, based on the horizontal gradient and the vertical gradient, determining the number of target pixel points on the traversed contour that are in the edge region; when the number of target pixel points is greater than or equal to the number threshold, obtaining a detection result for indicating that the corresponding contour is at the edge of the circumscribed rectangle; when the number of target pixel points is less than the number threshold, obtaining a detection result for indicating that the corresponding contour is not at the edge of the circumscribed rectangle.
[0120] In actual implementation, the process of determining the number of target pixel points on the traversed contour that are in the edge region based on the horizontal gradient and the vertical gradient specifically includes determining the edge intensity of each point (pixel point) on the traversed contour, and then taking the points with an edge intensity greater than or equal to the edge intensity threshold as the target pixel points in the edge region; then counting the number of target pixel points in the edge region.
[0121] It should be noted that both the number threshold and the edge intensity threshold are preset, and the embodiments of the present application do not limit this; and for the process of determining the edge intensity of each point (pixel point) on the traversed contour, it can be, for each pixel point on the traversed contour, summing the square of the horizontal gradient of the pixel point and the square of the vertical gradient of the pixel point to obtain a summation result; then performing a square root operation on the summation result to obtain the edge intensity of the pixel point, that is:
[0122]
[0123] Among them, E is the edge intensity of the pixel point, and I x is the horizontal gradient, and I y is the vertical gradient.
[0124] Exemplarily, referring to Figure 9 , Figure 9 is a schematic diagram of the edge of the circumscribed rectangle provided by the embodiment of the present application. Based on Figure 9 , the black border indicated by 901 is the edge of the circumscribed rectangle. Among them, the circumscribed rectangle here is also the Figure 9 circumscribed rectangle of the area indicated by 902, surrounded by the lines corresponding to multiple black solid dots in , and the edge of the circumscribed rectangle is also the side indicated by the length and width of the circumscribed rectangle.
[0125] In this way, since the circumscribed rectangle is determined to facilitate image processing, the contour of the circumscribed rectangle is not necessarily the line actually existing in the line drawing. At the same time, since the circumscribed rectangle is a closed figure, there cannot be gaps in the lines forming the circumscribed rectangle. Therefore, there is no need to process the gaps on the lines of the circumscribed rectangle based on the contour of the edge of the circumscribed rectangle. In this way, filtering out the contour of the edge of the circumscribed rectangle and not performing subsequent processing on the contour of the edge of the circumscribed rectangle not only reduces the amount of data to be processed, improves the image processing efficiency, but also reduces the useless image processing process, which is equivalent to reducing the waste of computing resources.
[0126] Step 103, for the contour of each line, when there is a break point on the contour, determine the connection point of the break point in the first closed area, and connect the break point and the connection point to obtain the target line.
[0127] It should be noted that for the contour of each line, before determining the connection point of the break point in the first closed area when there is a break point on the contour, it is first necessary to determine whether there is a break point on the contour. Among them, the break point here refers to the point that causes the line segment to be interrupted, that is, the break point of the line segment. For a break point, there is only a line segment on one side.
[0128] Based on this, in some embodiments, after extracting the contour of each said line, for the process of determining whether there is a break point on the contour, referring to Figure 10 , Figure 10 is a schematic flowchart of determining whether there is a break point on the contour provided by the embodiment of the present application. Based on Figure 10 , the process of determining whether there is a break point on the contour is implemented through the following steps.
[0129] Step 201, the server determines multiple points on each contour.
[0130] It should be noted that the process of determining multiple points on each contour can be to determine all the points (pixel points) on the contour for each contour; or, it can also be to sample all the points on each contour and use the sampled points as the points on the corresponding contour determined; among them, the sampling process here can be to sample all the points on the contour at intervals of a target number of pixel points, for example, sample every five pixel points.
[0131] Step 202: For each point, perform the following processing: Determine the preset distance condition corresponding to the point, and on the contour, find the first associated point and the second associated point that satisfy the preset distance condition; Based on the first associated point and the second associated point, determine whether the point is a break point on the contour.
[0132] It should be noted that the preset distance condition can be preset, for example, the distance from the current point reaches the target distance, that is, it is separated from the current point by a target number of pixel points. Among them, as described above, the contour line here is formed by pixel points. Therefore, for each point (pixel point) on the contour line, other points on the contour line are located on the left or right side of this point. So, there are two cases to find the points that satisfy the preset distance condition on the contour, that is, the point that satisfies the preset distance condition on the left side of this point and the point that satisfies the preset distance condition on the right side of this point.
[0133] Exemplarily, refer to Figure 11 , Figure 11 is a schematic diagram of the process of determining the first associated point and the second associated point provided by an embodiment of the present application. Based on Figure 11 , what 1101 indicates is a white line with a certain width, and the black frame wrapping the white line is the contour of the white line. Among them, the multiple black points shown on the black frame are pixel points forming the contour; Based on this, when the current point is the point indicated by 1102 and the preset distance condition is to be separated from the current point by 11 pixel points, then from both sides of the point indicated by 1102, find the pixel points on the contour that are separated from the current point by 11 pixel points, that is, the 12th pixel point. Here, taking the point indicated by 1103 as the 12th pixel point on the left side of the current point and the point indicated by 1104 as the 12th pixel point on the right side of the current point as an example, the point indicated by 1103 and the point indicated by 1104 are the first associated point and the second associated point.
[0134] In actual implementation, based on the first correlation point and the second correlation point, the process of determining whether a point is a break point on the contour may be as follows: connect the point with the first correlation point to obtain a first line segment, and connect the point with the second correlation point to obtain a second line segment; construct a target angle with the point as the vertex and the first line segment and the second line segment as the sides; when the angle of the target angle is less than or equal to the angle threshold, obtain the second distance between two target correlation points; when the second distance is less than or equal to the second distance threshold, determine the point as a break point on the contour.
[0135] It should be noted that the angle threshold can be preset, for example, 90 degrees, and the second distance threshold can also be preset. In this regard, the embodiments of the present application do not make any limitations.
[0136] As an example, refer to Figure 12 , Figure 12 is a schematic diagram showing that the angle of the target angle provided by the embodiment of the present application is greater than the angle threshold. Based on Figure 12 , taking the point indicated by 1201 as the current point, and the points indicated by 1202 and 1203 as the first correlation point and the second correlation point as an example, the angle of the target angle formed by these three points is greater than the angle threshold such as 90 degrees. Based on this, the point indicated by 1201 is not a break point.
[0137] As an example, refer to Figure 13 , Figure 13 is a schematic diagram showing that the second distance is greater than the second distance threshold provided by the embodiment of the present application. Based on Figure 13 , Figure 13 the point indicated by A in
[0138] is the current point. In this way, if the current point is at the forking position of the line, the target angle formed between the current point and the two correlation points may be less than the angle threshold such as 90 degrees. However, in this case, the distance between the two correlation points will definitely be large. Therefore, if the current point is a point at the forking position, even if the angle formed between the current point and the correlation points is less than the angle threshold, by judging whether the distance between the two correlation points is large, such as greater than the second distance threshold, the end points at the forking position can be excluded. Figure 14 Figure 14 Figure 14 is a schematic diagram of a break point provided by the embodiment of the present application. Based on Figure 14 , taking the point indicated by 1401 as the current point, and the points indicated by 1402 and 1403 as the first correlation point and the second correlation point as an example, the angle of the target angle formed by these three points is less than the angle threshold such as 90 degrees. At the same time, the distance between the correlation point indicated by 1402 and the correlation point indicated by 1403 is less than the distance threshold. In this way, it can be determined that the point indicated by 1401 is a break point on the line.
[0139] In this way, by setting a preset distance condition, the first associated point and the second associated point are searched for, so that based on the first associated point and the second associated point, it is determined whether the corresponding point is a break point on the contour, and by the angle of the target angle and the distance between the two associated points, the break point on the contour is determined, quantifying the recognition process of the break point, being able to correctly recognize the break point on the contour, and thus improving the accuracy when closing the gap caused by the break point in the subsequent process.
[0140] When actually implemented, when there is a break point on the contour, the process of determining the connection point of the break point in the first closed area can be to obtain multiple third associated points of the break point from the multiple points included in the contour, where the distance between the third associated point and the break point is less than or equal to the third distance threshold; perform linear fitting on the multiple third associated points to obtain a fitting line; and determine the connection point of the break point based on the fitting line.
[0141] It should be noted that the third distance threshold is also preset in advance, for example, it can be the same as the preset distance condition described above; then, after obtaining the multiple third associated points of the break point, perform linear fitting on the multiple third associated points. Here, the multiple third associated points are discrete multiple points, so the process of performing linear fitting on the multiple third associated points is also to establish a coordinate system for the corresponding line graph; in this coordinate system, obtain the coordinates of each third associated point, and based on the coordinates of each third associated point, use methods such as the least squares method to determine the target slope and the target intercept, and thus generate a fitting line based on the target slope and the target intercept.
[0142] It should be noted that assuming there is a linear relationship between data points, linear regression is to find a straight line such that the sum of the perpendicular distances (sum of squared residuals) from all points to this straight line is the smallest. In this case, based on the coordinates of each point, a slope and an intercept will be obtained, and thus a straight line is generated based on this slope and intercept, and this straight line is the fitting line obtained by the linear regression of multiple points.
[0143] In this way, perform linear regression on the multiple associated points of the break point to generate a fitting line, and thus determine the connection point of the break point based on the generated fitting line. In this way, since the fitting line is generated by passing through the multiple associated points of the break point, the fitting line is also related to the break point. Therefore, determining the connection point of the break point based on the fitting line reduces the error caused by manually selecting or estimating the position of the connection point while ensuring that the selected connection point is associated with the break point, improves the accuracy of the determined connection point, and thus improves the closing effect when closing the gap caused by the break point by connecting the break point and the connection point.
[0144] In actual implementation, the process of determining the connection point of the break point based on the fitted line can be to determine at least one intersection point of the fitted line and the lines in the line graph; from the at least one intersection point, select the intersection point closest to the break point as the connection point.
[0145] It should be noted that since the fitted line is a straight line, therefore, the fitted line in the line graph will form intersection points with multiple lines in the line graph. So, it is necessary to select the intersection point closest to the break point from the at least one intersection point as the connection point.
[0146] Exemplarily, refer to Figure 15 , Figure 15 is a schematic diagram of the connection point provided by the embodiment of the present application. Based on Figure 15 , the straight line indicated by 1501 is the fitted line. Thus, there will be multiple intersection points of this fitted line and the lines in the line graph, such as the intersection point indicated by 1502 and the intersection point indicated by 1503, etc. Thus, from the at least one intersection point, select the intersection point closest to the break point, that is, the intersection point indicated by 1502, as the connection point.
[0147] In this way, select the intersection point closest to the break point from the at least one intersection point formed by the fitted line of the break point and multiple lines in the line graph as the connection point of the break point. In this way, by minimizing the distance between the connection point and the break point, the error introduced due to incorrect connection is reduced, and the accuracy of the determined connection point is improved. Thus, the closing effect when closing the gap caused by connecting the break point and the connection point is improved; at the same time, it is ensured that the selection of the connection point is based on distance, thereby improving the accuracy of the connection and making the reconstruction of the line, that is, the closing of the gap, more accurate.
[0148] In actual implementation, the interruption of the line may be unconscious, and at this time, gap closing is required. However, sometimes the line is deliberately interrupted by the drawer, and in this case, gap closing is not required; therefore, not every gap corresponding to a break point needs to be closed. Based on this, before connecting the break point and the connection point to obtain the target line, it is also possible to obtain the first distance between the point and the connection point; thus, the process of connecting the break point and the connection point to obtain the target line can be that when the first distance is less than or equal to the first distance threshold, it is determined that there is a gap between the break point and the connection point, and the break point and the connection point are connected to obtain the target line for closing the gap.
[0149] It should be noted that the first distance threshold here can be preset. For example, a distance of 20 pixel points is set. Thus, when the first distance is less than or equal to the first distance threshold, it is determined that there is a gap that needs to be closed between the break point and the connection point; when the first distance is greater than the first distance threshold, it is determined that the gap between the break point and the connection point does not need to be closed.
[0150] Exemplarily, refer to Figure 16 , Figure 16 which are schematic diagrams of two line break methods provided by an embodiment of the present application. Based on Figure 16 , Figure 16 in a, what is indicated by 1601 is the gap that needs to be closed, while Figure 16 in b, what is indicated by 1602 is the position that does not need to be closed.
[0151] Thus, since not all line breaks are gaps that need to be closed, by setting a first distance threshold, when the first distance between the break point and the connection point is less than or equal to the first distance threshold, it is determined that there is a gap that needs to be closed between the break point and the connection point, and then the corresponding gap is closed; in this way, it is possible to reduce the misclosure of gaps that do not need to be closed and avoid misidentifying areas that do not need to be closed as gaps that need to be closed; at the same time, through threshold filtering, only those gaps that truly need to be closed can be closed, thereby improving the accuracy of the closing operation.
[0152] In some embodiments, as described above, the first distance threshold here can be preset. Specifically, in response to a coloring request for a line graph, before determining a first closed area including the trigger position in the line graph based on the trigger position of the coloring request in the line graph, it is also possible to receive a coloring request for the line graph sent by the terminal and carrying the first distance threshold, where the first distance threshold is used to determine whether there is a gap between the break point and the connection point.
[0153] It should be noted that here, the terminal first displays a setting interface for the distance threshold; in response to a threshold setting operation performed in the setting interface, the set distance threshold is displayed, and in response to a confirmation instruction, the set distance threshold is determined as the first distance threshold; among them, the setting interface for the distance threshold and the setting process of the first distance threshold will be described below, and the embodiments of the present application will not elaborate here.
[0154] Then, after the terminal determines the set distance threshold as the first distance threshold, in response to a coloring operation for the line graph, a coloring request for the line graph and carrying the first distance threshold is generated and sent to the server.
[0155] Step 104, based on the target line and the trigger position, determine a second closed area including the trigger position in the first closed area and color the second closed area.
[0156] It should be noted that in the first closed area, after the lines that need gap closing are closed, the first closed area can be newly divided into multiple closed areas, or after the lines that need gap closing are closed, it will not affect the first closed area, that is, the first closed area will not be newly divided into multiple closed areas.
[0157] In some embodiments, for a line that needs to have its gap closed, after closing, if it does not affect the first closed region, in this case, the line that needs to have its gap closed, after closing, will not have an impact on the first closed region, that is, a new closed region including the trigger position will not be re-formed based on the target line. The second closed region determined in the first closed region and including the trigger position is the first closed region itself. Therefore, coloring the second closed region in the subsequent process is to color the first closed region.
[0158] Exemplarily, refer to Figure 17 , Figure 17 which is a schematic diagram of the second closed region provided by an embodiment of the present application. Based on Figure 17 , the first closed region formed by a plurality of black solid dots, if the gap indicated by 1701 is closed, the closed line will not divide the first closed region into new closed regions. Therefore, it will not have an impact on the first closed region formed by the plurality of black solid dots.
[0159] In some other embodiments, for a line that needs to have its gap closed, after closing, it can divide the first closed region into multiple closed regions; specifically, in the process of determining the second closed region including the trigger position in the first closed region based on the target line and the trigger position, it can be to determine the closed line formed by the target line and surrounding the trigger position, and in the first closed region, take the region surrounded by the closed line as the second closed region.
[0160] It should be noted that in this case, the line that needs to have its gap closed, after closing, will re-form a new closed region including the trigger position based on the target line. Thus, coloring the second closed region in the subsequent process is to color this new closed region.
[0161] Exemplarily, refer to Figure 18 , Figure 18 which is a schematic diagram of the second closed region provided by an embodiment of the present application. Based on Figure 18 , the first closed region formed by a plurality of black solid dots, if the gap indicated by 1801 is closed, the closed line will divide the first closed region into new closed regions. Therefore, it will have an impact on the first closed region formed by the plurality of black solid dots.
[0162] In this way, a closed line consisting of the target line formed after the gap is closed and surrounding the trigger position is determined, so that the area surrounded by the closed line is used as the second closed area to be colored. In this way, it is ensured that the coloring operation only occurs within the closed area predetermined by the user, thereby improving the accuracy and consistency of coloring. At the same time, by defining a clearly defined closed area, the coloring operation can be prevented from overflowing into an area that is not desired to be colored, thereby reducing the risk of color overflow or contamination.
[0163] In actual implementation, the process of coloring the second closed area can be to determine the target color corresponding to the coloring request and fill the area surrounded by the closed line with the target color; obtain the current color of the closed line, and when the current color is inconsistent with the target color, adjust the closed line from the current color to the target color.
[0164] It should be noted that the target color is the color set by the user for filling; and when the current color is consistent with the target color, the color of the closed line does not need to be adjusted, and only the area surrounded by the closed line needs to be filled with the target color.
[0165] For example, see Figure 19 , Figure 19 is a schematic diagram of the second closed area after coloring provided in an embodiment of the present application, based on Figure 19 , Figure 19 The black area indicated by 1901 is the second closed area after coloring.
[0166] In this way, when the current color of a closed line is inconsistent with the target color, by adjusting the closed line from the current color to the target color, the color of the closed line is adjusted to ensure that it is consistent with the target color, which helps to maintain the overall color coordination and consistency of the image and avoid leaving gaps in the connecting line.
[0167] As an example, for the field of game production:
[0168] In response to a coloring request for a game line drawing, based on the trigger position of the coloring request in the game line drawing, a first closed area including the trigger position is determined in the game line drawing; in the game line drawing, multiple game line drawings associated with the first closed area are determined, and the contour lines of each game line drawing are extracted; for the contour lines of each game line drawing, when there are breakpoints on the contour lines, the connection points of the breakpoints are determined in the first closed area, and the breakpoints and the connection points are connected to obtain the target game line drawing; based on the target line and the trigger position, a second closed area including the trigger position is determined in the first closed area, and the second closed area is colored.
[0169] In some embodiments, Figure 1Taking the medium terminal 400 in [the relevant context] as an example to separately execute the method for coloring the line graph provided in the embodiments of the present application for illustration. Refer to Figure 20 , Figure 20 which is a schematic flowchart of the method for coloring the line graph provided in the embodiments of the present application. Next, it will be described in combination with Figure 20 the steps shown.
[0170] Step 301, the terminal displays a setting interface for the distance threshold.
[0171] In actual implementation, in response to a display instruction for the line graph, before displaying the line graph, a setting interface for the distance threshold is displayed, so as to facilitate closing the gap based on the set first distance threshold in the subsequent process. Exemplarily, refer to Figure 21 , Figure 21 which is a schematic diagram of the setting interface for the distance threshold provided in the embodiments of the present application. Based on Figure 21 , the area indicated by the dashed box 2101 is the setting interface for the distance threshold.
[0172] Step 302, in response to a threshold setting operation performed in the setting interface, the set distance threshold is displayed.
[0173] It should be noted that, as Figure 21 shown by the dashed box 2101 in [the relevant figure], if multiple candidate thresholds are displayed in the setting interface, then the threshold setting operation here can be a selection operation for the target candidate threshold among the multiple candidate thresholds. Thus, in response to the selection operation for the target candidate threshold, the target candidate threshold is controlled to be in a selected state, and then the target candidate threshold in the selected state is used as the set distance threshold.
[0174] Step 303, in response to a determination instruction, the set distance threshold is determined as the first distance threshold, and the first distance threshold is used to determine whether there is a gap between the break point and the connection point.
[0175] It should be noted that the break point and the connection point here are the same as those described above, and will not be elaborated in the embodiments of the present application here.
[0176] Step 304, after the set distance threshold is determined as the first distance threshold, in response to a coloring request triggered by a coloring operation for the line graph, based on the trigger position of the coloring request in the line graph, a first closed area including the trigger position is determined in the line graph.
[0177] It should be noted that the trigger position of the coloring request in the line graph is also the trigger position of the coloring operation in the line graph. Among them, as Figure 4As shown, a line drawing is an image with lines as the main elements. It depicts the outline, structure, or dynamics of an object through changes in the thickness, length, curvature, and density of the lines. Among them, the line drawing here at least includes a line draft, a structure diagram, or a technical drawing, etc. A line draft is a sketch or drawing with lines as the main elements, usually used to depict the outline and structure of an object, without relying on shading, texture, or color to represent the three-dimensional sense or texture of the object.
[0178] In actual implementation, in response to a coloring request triggered by a coloring operation on the line drawing, based on the triggering position of the coloring request in the line drawing, the process of determining a first closed area including the triggering position in the line drawing is similar to the process described above in response to a coloring request on the line drawing, based on the triggering position of the coloring request in the line drawing, and determining a first closed area including the triggering position in the line drawing. For this, the embodiments of the present application will not elaborate.
[0179] Step 305: In the line drawing, determine multiple lines associated with the first closed area, and extract the outlines of each line.
[0180] In actual implementation, the process of determining multiple lines associated with the first closed area and extracting the outlines of each line in the line drawing is also the same as the process described above of determining multiple lines associated with the first closed area and extracting the outlines of each line in the line drawing. For this, the embodiments of the present application will not elaborate either.
[0181] Step 306: For the outline of each line, when there is a break point on the outline, determine the connection point of the break point in the first closed area, and connect the break point and the connection point to obtain the target line.
[0182] In actual implementation, for the outline of each line, when there is a break point on the outline, the process of determining the connection point of the break point in the first closed area and connecting the break point and the connection point to obtain the target line is as described above for the outline of each line, when there is a break point on the outline, determining the connection point of the break point in the first closed area and connecting the break point and the connection point to obtain the target line. For this, the embodiments of the present application will not elaborate either.
[0183] Step 307: Based on the target line and the triggering position, determine a second closed area including the triggering position in the first closed area, and color the second closed area.
[0184] In actual implementation, the process of determining a second closed region including the trigger position in the first closed region based on the target line and the trigger position and coloring the second closed region is similar to the process described above of determining a second closed region including the trigger position in the first closed region based on the target line and the trigger position and coloring the second closed region. Therefore, this application embodiment will not elaborate on this.
[0185] Applying the above embodiments of this application, when a coloring request for a line drawing is received, based on the trigger position of the coloring request, a first closed region including the trigger position is determined in the line drawing, and the outlines of each line associated with the first closed region in the line drawing are extracted. Thus, when there are breakpoints on the outline and connection points of the breakpoints are determined in the first closed region, the breakpoints and the connection points are connected, and based on the obtained target line and the trigger position, a second closed region including the trigger position is determined in the first closed region, and then the second closed region is colored. In this way, based on the first closed region in the line drawing, the breakpoints on the lines in the line drawing and the corresponding connection points are analyzed, so as to connect the breakpoints and the corresponding connection points. In this way, compared with the solution in the related art that needs to traverse all points in the line drawing to extract the skeleton to achieve gap closing, by analyzing the local region of the line drawing, the gaps caused by the breakpoints on the lines in the line drawing are obtained, so as to close the gaps, reducing the data processing level, improving the image processing speed and processing efficiency, that is, improving the closing efficiency when closing the gaps caused by the breakpoints on the lines in the line drawing, thereby improving the coloring efficiency of the line drawing. At the same time, the user experience is also improved, and the user processing waiting time is reduced.
[0186] Next, an exemplary application of the embodiments of this application in an actual application scenario will be described.
[0187] With the rapid development of the animation industry, there are higher production requirements and shorter production cycles. In this environment, it is crucial to improve the efficiency of anime coloring. However, gaps always occur during the process of drawing line art in the studio (the situation where two lines should be connected but are not), so it is necessary to find a method to quickly close the gaps and achieve quick closing and coloring. The most commonly used gap closing method in the related art is to thin the image and then extract the skeleton from the thinned image and then close the gaps. However, such a method requires traversing all points in the image and extracting the skeleton, with low efficiency. In the face of images with large resolutions or multiple images, the data processing level is too large and the calculation is slow.
[0188] Based on this, the present application provides a method for coloring a line graph. According to the value of the preset closed gap (the first distance threshold), the selected blank area is processed to achieve rapid closing of the gap. In this way, through local processing, the data processing level is reduced, the processing speed and efficiency are improved, thereby greatly increasing the coloring speed and reducing the user's coloring error rate; at the same time, the user's processing waiting time is reduced, improving the user experience.
[0189] Next, the technical solution of the present application will be described from the product side.
[0190] In actual implementation, in response to the opening operation of the coloring tool, the line draft or color draft to be imported is displayed; then in response to the selection operation of the line draft, the line draft to be colored is displayed; where, as Figure 21 shown, in the displayed line draft, it is also shown that there are gaps where the line segments in the line draft are not closed, and at the same time, the setting interface for the gap threshold is displayed, so that in response to the gap threshold setting operation triggered based on the setting interface, we set the value of the closed gap.
[0191] Then, there is no need to manually connect the gaps, and normal coloring can be performed. Specifically, in response to the coloring operation on the blank area, the coloring result is displayed, as Figure 19 shown, the colored area is filled with color normally and the color lines are also colored, that is, the gaps will be closed and colored normally and the left part of the line draft with gaps during the process is not filled with any color, and the coloring result is correct.
[0192] Next, the technical solution of the present application will be described from the technical side.
[0193] In actual implementation, referring to Figure 22 , Figure 22 is the flowchart of the method for coloring a line graph provided by the embodiment of the present application. Based on Figure 22, the coloring method of the line graph provided by the embodiment of the present application is implemented through steps 2201 to 2213; specifically, in step 2201, first receive the setting operation and coloring operation for the gap threshold, that is, set the threshold for gap closing; steps 2202 - 2205, receive the click operation for the blank area to perform color filling, and obtain the bounding rectangle and its binary result, and then obtain multiple external contours. Specifically, when receiving the click operation for the blank area (that is, the coloring operation for the blank area), according to the trigger position of the click operation, find the edge of the blank area (the first closed area), and at the same time use the boundingRect method of OpenCV to find the minimum bounding rectangle (bounding rectangle) of the edge; then, binarize the minimum bounding rectangle, so that after binarization is completed, use the findContours method to obtain the contours of the lines in the entire area; steps 2206 - 2208, traverse each contour, filter the edge contours, and then for each point on the contour, find its two associated points, and determine whether the current point is an end point based on the associated points. Specifically, there may be multiple contours here, so each contour needs to be traversed. First, it is necessary to determine whether the line corresponding to the current contour is the edge line of the bounding rectangle; if the line corresponding to the current contour is not the edge line of the bounding rectangle, then the breadth-first search algorithm (BFS, Breadth-First Search) can be executed for all points inside the contour, so as to search for 2 associated points (the first associated point and the second associated point) of the current point based on a preset threshold (preset distance adjustment). Among them, the breadth-first search algorithm is an algorithm used to traverse or search trees and graphs. It starts from the starting node and traverses all adjacent nodes layer by layer until the target node is found or the entire tree or graph is traversed; then calculate the distance between these two points and the included angle with the current point to determine whether the current point is an end point (break point);
[0194] Steps 2209 - 2210, when it is determined that the current point is an end point, determine the connection point of the current point, and connect the end point with the corresponding connection point. That is, in the process of searching for 2 associated points of the current point point by point based on a preset threshold, each point that is not an associated point found will be marked, and then for each end point, determine the marked point (the third associated point) corresponding to the end point, and then perform linear regression on each marked point to obtain the fitting line, and then find the connection point closest to the current end point through the fitting line.
[0195] It should be noted that since there may be multiple end points, therefore, the above process will be executed for each end point to complete the gap closing.
[0196] Steps 2211 - 2213, obtain the sub-region after closing the gap and color the sub-region, thereby completing the coloring. Specifically, after connecting the endpoints to the corresponding connection points, based on the closed gap and the trigger position of the coloring operation, obtain the sub-region (the second closed region) in the initially filled region (the first closed region), that is, the region where the closing is completed; finally, color the sub-region. At the same time, to avoid leaving gaps in the connection lines, color the connection lines as well.
[0197] In this way, through the technical solution of the present application, not only can the overall efficiency of coloring the line drawing be improved, but also the time for the user to manually repair the line drawing can be reduced; moreover, it is possible to avoid a large number of situations where the color overflows during the coloring process due to gaps in the line drawing, improving the accuracy of the coloring result; in addition, because the minimum bounding rectangle is used for local processing, the data processing level can also be reduced, improving the processing speed and processing efficiency, and at the same time, it can also improve the user experience and reduce the user's processing waiting time.
[0198] Applying the above embodiments of the present application, when receiving a coloring request for a line drawing, based on the trigger position of the coloring request, determine the first closed region including the trigger position in the line drawing, and extract the outline of each line associated with the first closed region in the line drawing. Thus, when there is a break point on the outline and the connection point of the break point is determined in the first closed region, connect the break point and the connection point, and based on the obtained target line and the trigger position, determine the second closed region including the trigger position in the first closed region, and then color the second closed region. In this way, based on the first closed region in the line drawing, analyze the break points on the lines in the line drawing and the corresponding connection points, and thus connect the break points and the corresponding connection points. In this way, compared with the related art where all points in the line drawing need to be traversed to extract the skeleton to achieve gap closure, by analyzing the local region of the line drawing, obtain the gaps caused by the break points on the lines in the line drawing, and thus close the gaps, reducing the data processing level, improving the image processing speed and processing efficiency, that is, improving the closing efficiency when closing the gaps caused by the break points on the lines in the line drawing, thereby improving the coloring efficiency of the line drawing, and at the same time, it can also improve the user experience and reduce the user's processing waiting time.
[0199] Next, continue to describe the exemplary structure of the software module implementation of the line drawing coloring device 455 provided by the embodiments of the present application. In some embodiments, as Figure 2 shown, the software modules stored in the line drawing coloring device 455 in the memory 450 may include:
[0200] The first determination module 4551 is configured to, in response to a coloring request for a line graph, determine a first closed region including the trigger position in the line graph based on the trigger position in the coloring request in the line graph;
[0201] The second determination module 4552 is configured to determine a plurality of lines associated with the first closed region in the line graph and extract the outlines of the respective lines;
[0202] The connection module 4553 is configured to, for the outline of each line, when there is a break point on the outline, determine a connection point of the break point in the first closed region and connect the break point and the connection point to obtain a target line;
[0203] The coloring module 4554 is configured to determine a second closed region including the trigger position in the first closed region based on the target line and the trigger position and color the second closed region.
[0204] In some embodiments, the second determination module 4552 is further configured to determine a circumscribed rectangle of the first closed region in the line graph; and determine the plurality of lines included in the circumscribed rectangle as the plurality of lines associated with the first closed region.
[0205] In some embodiments, the second determination module 4552 is further configured to determine a circumscribed rectangle of the first closed region in the line graph; perform binarization processing on the circumscribed rectangle to obtain a binarized rectangle of the circumscribed rectangle; extract binarized lines in the binarized rectangle, and determine the extracted binarized lines as the outlines of the respective lines.
[0206] In some embodiments, the apparatus further includes a traversal module, and the traversal module is configured to determine a circumscribed rectangle of the first closed region in the line graph and traverse each of the outlines; during the traversal process, detect the traversed outline based on the circumscribed rectangle to obtain a detection result, where the detection result is used to indicate whether the outline is at the edge of the circumscribed rectangle; based on each of the detection results, filter out the outlines at the edge of the circumscribed rectangle from the plurality of outlines to obtain target outlines; the connection module 4553 is further configured to, for each of the target outlines, when there is a break point on the target outline, determine a connection point of the break point in the first closed region.
[0207] In some embodiments, the first determination module 4551 is further configured to perform color filling on the closed region where the trigger position is located in the line graph to obtain a filled closed region; and determine the filled closed region as the first closed region.
[0208] In some embodiments, the device further includes an acquisition module configured to acquire a first distance between the break point and the connection point; the connection module 4553 is further configured to determine that there is a gap between the break point and the connection point when the first distance is less than or equal to a first distance threshold, and connect the break point and the connection point to obtain a target line for closing the gap.
[0209] In some embodiments, the device further includes a threshold setting module configured to display a setting interface for the distance threshold; in response to a threshold setting operation performed in the setting interface, display the set distance threshold; in response to a determination instruction, determine the set distance threshold as the first distance threshold, where the first distance threshold is used to determine whether there is a gap between the break point and the connection point.
[0210] In some embodiments, the device further includes a search module configured to determine a plurality of points on each of the contours, and for each of the points, perform the following processing: determine a preset distance condition corresponding to the point, and search for a first associated point and a second associated point that satisfy the preset distance condition on the contour; based on the first associated point and the second associated point, determine whether the point is a break point on the contour.
[0211] In some embodiments, the search module is further configured to connect the point and the first associated point to obtain a first line segment, and connect the point and the second associated point to obtain a second line segment; construct a target angle with the point as the vertex and the first line segment and the second line segment as the sides; when the angle of the target angle is less than or equal to an angle threshold, acquire a second distance between the two target associated points; when the second distance is less than or equal to a second distance threshold, determine the point as a break point on the contour.
[0212] In some embodiments, the connection module 4553 is further configured to acquire a plurality of third associated points of the break point from the plurality of points included in the contour, where the distance between the third associated point and the break point is less than or equal to a third distance threshold; perform linear fitting on the plurality of third associated points to obtain a fitting line; based on the fitting line, determine the connection point of the break point.
[0213] In some embodiments, the connection module 4553 is further configured to determine at least one intersection point between the fitting line and a line in the line graph; select, from the at least one intersection point, the intersection point closest to the break point as the connection point.
[0214] In some embodiments, the coloring module 4553 is further configured to determine a closed line formed by the target lines that encloses the trigger position, and in the first closed region, use the region enclosed by the closed line as the second closed region.
[0215] In some embodiments, the coloring module 4553 is further configured to determine a target color corresponding to the coloring request, and fill the region enclosed by the closed line with the target color; obtain the current color of the closed line, and when the current color is inconsistent with the target color, adjust the closed line from the current color to the target color.
[0216] An embodiment of the present application provides a computer program product, which includes computer-executable instructions or a computer program, and the computer-executable instructions or the computer program are stored in a computer-readable storage medium. The processor of the electronic device reads the computer-executable instructions or the computer program from the computer-readable storage medium, and the processor executes the computer-executable instructions or the computer program, so that the electronic device executes the coloring method of the line drawing in the embodiments of the present application as described above.
[0217] An embodiment of the present application provides a computer-readable storage medium storing computer-executable instructions or a computer program. When the computer-executable instructions or the computer program are executed by a processor, it will cause the processor to execute the coloring method of the line drawing provided by the embodiments of the present application. For example, Figure 3 the coloring method of the line drawing shown.
[0218] In some embodiments, the computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a flash memory, a magnetic surface memory, an optical disc, or a CD-ROM, etc.; it may also be various devices including one or any combination of the above memories.
[0219] In some embodiments, the computer-executable instructions may be in the form of a program, software, a software module, a script, or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including being deployed as an independent program or being deployed as a module, a component, a subroutine, or other units suitable for use in a computing environment.
[0220] As an example, the computer-executable instructions may or may not correspond to files in a file system, and may be stored as part of a file that stores other programs or data. For example, they may be stored in one or more scripts in a HyperText Markup Language (HTML) document, stored in a single file dedicated to the program being discussed, or stored in multiple cooperating files (e.g., files that store one or more modules, subroutines, or code portions).
[0221] As an example, the computer-executable instructions may be deployed to execute on one electronic device, or on multiple electronic devices located at one location, or on multiple electronic devices distributed at multiple locations and interconnected by a communication network.
[0222] In summary, the embodiments of the present application have the following beneficial effects:
[0223] (1) Based on the first closed region in the line drawing, the breakpoints on the lines in the line drawing and the corresponding connection points are analyzed, and then the breakpoints and the corresponding connection points are connected. In this way, compared with the solution in the related art that needs to traverse all points in the line drawing to extract the skeleton to achieve gap closure, by analyzing the local region of the line drawing, the gaps caused by the breakpoints on the lines in the line drawing are obtained, and then the gaps are closed, reducing the data processing magnitude, improving the image processing speed and processing efficiency, that is, improving the closure efficiency when closing the gaps caused by the breakpoints on the lines in the line drawing, thereby improving the coloring efficiency of the line drawing. At the same time, the user experience is also improved, and the user's processing waiting time is reduced.
[0224] (2) Through the technical solution of the present application, not only can the overall efficiency of coloring the line drawing be improved, but also the time for the user to manually repair the line drawing can be reduced; moreover, it can avoid a large number of situations where the color overflows during the coloring process due to gaps in the line drawing, improving the accuracy of the coloring result; in addition, because the minimum bounding rectangle is used for local processing, the data processing magnitude can also be reduced, the processing speed and processing efficiency can be improved, and at the same time, the user experience can also be improved, and the user's processing waiting time can be reduced.
[0225] (3) By filling the area where the trigger position of the coloring request is located to determine the closed region where the trigger position is located, the boundary detection can be performed using the filling operation, so as to find and color along the edge of the closed region, which is convenient for determining the closed region where the trigger position is located, that is, improving the determination efficiency of the closed region where the trigger position is located.
[0226] (4) By determining the circumscribed rectangle of the first closed region, and then based on the circumscribed rectangle, determining multiple lines, that is, processing based on the circumscribed rectangle. In this way, since the size of the circumscribed rectangle is definitely smaller than the size of the line drawing, not only can the image processing task be simplified, the amount of data for image processing be reduced, and the image processing efficiency be improved, but also the analysis can focus on the first closed region itself while ignoring other irrelevant background information, thereby improving the accuracy of the image processing result, that is, improving the accuracy of the extracted lines.
[0227] (5) By performing binarization processing on the circumscribed rectangle of the closed region, the contour lines of the lines included in the circumscribed rectangle are obtained. In this way, on the premise of ensuring the image information, the image is simplified through binarization processing. Since binarization processing converts the image into a simplified representation containing only two colors, black and white, the image is simplified on the premise of ensuring the image information, thus simplifying the subsequent image processing process; at the same time, through binarization processing, the line boundaries inside the circumscribed rectangle can be clearly extracted, facilitating the further analysis and recognition of the shape of the lines in the image, thereby improving the extraction efficiency and accuracy of the line contours.
[0228] (6) Since determining the circumscribed rectangle is for the convenience of image processing, the contour of the circumscribed rectangle is not necessarily the actual line in the line drawing. At the same time, since the circumscribed rectangle is a closed figure, there cannot be gaps in the lines forming the circumscribed rectangle. Therefore, there is no need to process the gaps on the lines of the circumscribed rectangle based on the contour of the edge of the circumscribed rectangle. In this way, filtering out the contour of the edge of the circumscribed rectangle and not performing subsequent processing on the contour of the edge of the circumscribed rectangle not only reduces the amount of data to be processed, improves the image processing efficiency, but also reduces the useless image processing process, which is equivalent to reducing the waste of computing resources.
[0229] (7) By setting a preset distance condition to find the first associated point and the second associated point, and then based on the first associated point and the second associated point, determining whether the corresponding point is a break point on the contour, and also determining the break point on the contour through the angle of the target angle and the distance between the two associated points, quantifying the recognition process of the break point, being able to correctly identify the break point on the contour, and thus improving the accuracy when closing the gap caused by the break point in the subsequent process.
[0230] (8) Since the interruption of a line does not necessarily mean a gap that needs to be closed, by setting a first distance threshold, when the first distance between a break point and a connection point is less than or equal to the first distance threshold, it is determined that there is a gap that needs to be closed between the break point and the connection point, and then the corresponding gap is closed; in this way, the misclosure of gaps that do not need to be closed can be reduced, and the area that does not need to be closed can be prevented from being wrongly regarded as a gap that needs to be closed; at the same time, through threshold filtering, only those gaps that really need to be closed can be closed, thereby improving the accuracy of the closing operation.
[0231] It should be noted that in the embodiments of the present application, data related to user operations, line diagrams, etc. are involved. When the embodiments of the present application are applied to specific products or technologies, user permission or consent is required, and the collection, use, and processing of relevant data need to comply with the relevant laws, regulations, and standards of relevant countries and regions.
[0232] The above is only the embodiments of the present application and is not intended to limit the protection scope of the present application. Any modifications, equivalent replacements, and improvements made within the spirit and scope of the present application are included in the protection scope of the present application.
Claims
1. A method for coloring a line drawing, characterized in that: The method comprises: In response to a coloring request for a line drawing, based on a triggering position of the coloring request in the line drawing, determining a first closed area in the line drawing including the triggering position; In the line graph, determining a plurality of lines associated with the first closed area, and extracting a contour of each of the lines; For the contour of each of the lines, when there are breakpoints on the contour, determining the connection points of the breakpoints in the first closed area, and connecting the breakpoints and the connection points to obtain a target line; Based on the target line and the trigger position, a second closed area including the trigger position is determined in the first closed area, and the second closed area is colored.
2. The method according to claim 1, characterized in that: Determining, in the line graph, a plurality of lines associated with the first closed area comprises: In the line drawing, determining a circumscribed rectangle of the first closed area; The multiple lines included in the circumscribed rectangle are determined as the multiple lines associated with the first closed area.
3. The method according to claim 1, characterized in that: The extracting the contour of each of the lines comprises: In the line drawing, determining a circumscribed rectangle of the first closed area; Binarizing the circumscribed rectangle to obtain a binary rectangle of the circumscribed rectangle; Binarized lines in the binary rectangle are extracted, and the extracted binary lines are determined as contours of each of the lines.
4. The method according to claim 1, characterized in that: After extracting the contour of each of the lines, the method further comprises: In the line drawing, determining the circumscribed rectangle of the first closed area, and traversing each of the contours; During the traversal process, based on the circumscribed rectangle, the traversed contour is detected to obtain a detection result, wherein the detection result is used to indicate whether the contour is at the edge of the circumscribed rectangle; Based on the detection results, filter out contours at the edge of the circumscribed rectangle from the multiple contours to obtain a target contour; For the contour of each of the lines, when there are breakpoints on the contour, determining the connection points of the breakpoints in the first closed area includes: For each of the target contours, when there are breakpoints on the target contour, connecting points of the breakpoints are determined in the first closed region.
5. The method according to claim 1, characterized in that: The determining, based on a trigger position of the coloring request in the line drawing, a first closed area including the trigger position in the line drawing comprises: In the line graph, filling the closed area where the trigger position is located with color to obtain a filled closed area; The filled closed area is determined as the first closed area.
6. The method according to claim 1, characterized in that: Before connecting the breakpoints and the connection points to obtain the target line, the method further includes: Acquire a first distance between the breakpoint and the connection point; The step of connecting the breakpoints and the connection points to obtain a target line includes: When the first distance is less than or equal to a first distance threshold, it is determined that there is a gap between the breakpoint and the connection point, and the breakpoint and the connection point are connected to obtain a target line for closing the gap.
7. The method according to claim 6, characterized in that In response to a coloring request for a line drawing, based on a triggering position of the coloring request in the line drawing, before determining a first closed area including the triggering position in the line drawing, the method further includes: Display the distance threshold setting interface; In response to a threshold setting operation performed in the setting interface, displaying a set distance threshold; In response to the determination instruction, the set distance threshold is determined as the first distance threshold, and the first distance threshold is used to determine whether there is a gap between the breakpoint and the connection point.
8. The method according to any one of claims 1 to 7, characterized in that: After extracting the contour of each of the lines, the method further comprises: Determine a plurality of points on each of the contours, and perform the following processing for each of the points: Determine a preset distance condition corresponding to the point, and search for a first associated point and a second associated point on the contour that satisfy the preset distance condition; Based on the first associated point and the second associated point, it is determined whether the point is a breakpoint on the contour.
9. The method according to claim 8, characterized in that: The step of determining whether the point is a breakpoint on the contour based on the first associated point and the second associated point includes: Connecting the point with the first associated point to obtain a first line segment, and connecting the point with the second associated point to obtain a second line segment; Constructing a target angle by taking the point as a vertex and the first line segment and the second line segment as edges; When the target angle is less than or equal to the angle threshold, obtaining a second distance between the two target associated points; When the second distance is less than or equal to a second distance threshold, the point is determined as a breakpoint on the contour.
10. The method according to any one of claims 1 to 7, characterized in that: When there are breakpoints on the contour, determining the connection points of the breakpoints in the first closed area comprises: Acquire a plurality of third associated points of the breakpoint from a plurality of points included in the contour, wherein the distance between the third associated point and the breakpoint is less than or equal to a third distance threshold; Performing linear fitting on the plurality of third associated points to obtain a fitting line; Based on the fitting line, connection points of the breakpoints are determined.
11. The method according to claim 10, characterized in that: The step of determining the connection point of the breakpoints based on the fitting line includes: determining at least one intersection point of the fitted line with a line in the line graph; From the at least one intersection point, select the intersection point closest to the breakpoint as the connection point.
12. The method according to any one of claims 1 to 7, characterized in that: The step of determining a second closed area including the trigger position in the first closed area based on the target line and the trigger position comprises: A closed line formed by the target line and surrounding the trigger position is determined, and in the first closed area, the area surrounded by the closed line is used as the second closed area.
13. The method according to claim 12, characterized in that: The coloring of the second closed area includes: Determine a target color corresponding to the coloring request, and fill the area surrounded by the closed line with the target color; The current color of the closed line is obtained, and when the current color is inconsistent with the target color, the closed line is adjusted from the current color to the target color.
14. A coloring device for a line drawing, characterized in that: The device comprises: A first determining module, configured to respond to a coloring request for a line drawing and determine, based on a triggering position of the coloring request in the line drawing, a first closed area in the line drawing including the triggering position; A second determination module, configured to determine, in the line graph, a plurality of lines associated with the first closed area, and extract a contour of each of the lines; a connection module, for determining, for each of the contours of the lines, connection points of the breakpoints in the first closed area when there are breakpoints on the contours, and connecting the breakpoints and the connection points to obtain a target line; A coloring module is used to determine a second closed area including the trigger position in the first closed area based on the target line and the trigger position, and to color the second closed area.
15. An electronic device, characterized in that: include: Memory for storing computer executable instructions or computer programs; A processor, configured to implement the line drawing coloring method according to any one of claims 1 to 13 when executing the computer executable instructions or computer program stored in the memory.
16. A computer-readable storage medium, characterized in that: Computer executable instructions or computer programs are stored, which are used to cause a processor to execute and implement the line drawing coloring method described in any one of claims 1 to 13.
17. A computer program product comprising computer executable instructions or a computer program, characterized in that When the computer executable instructions or computer program are executed by a processor, the line drawing coloring method described in any one of claims 1 to 13 is implemented.