Line rendering methods, devices, electronic equipment and storage media
By replacing edge lines with texture images that match the image during image processing, the problem of monotonous line rendering is solved, resulting in a rich visual experience and fast rendering.
Patent Information
- Application Number
- CN202211163555.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-23
- Publication Date
- 2026-11-10
- Estimated Expiration
- 2042-09-23
AI Technical Summary
The fixed line rendering method in existing technologies leads to visual monotony, causes visual fatigue, and reduces user experience.
By acquiring the target region in the image, performing edge detection, selecting a texture image that matches the image, and replacing the lines according to the position of the edge lines, diverse texture rendering can be achieved.
It provides a rich visual experience, reduces visual fatigue, improves user experience, speeds up line rendering, and reduces complexity.
Smart Images

Figure CN117765105B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, specifically to a line rendering method, apparatus, electronic device, and storage medium. Background Technology
[0002] Adding lines to images is a common feature in various image and video editing apps, typically used to highlight or enhance information within a specific area. Current techniques often involve defining the edge lines of an area, selecting a few fixed texture patterns, and then progressively rendering these patterns onto the edge lines based on their starting points. However, because the texture patterns are fixed, this line rendering method can become visually monotonous and cause eye strain over time, ultimately reducing the user experience. Summary of the Invention
[0003] This application provides a line rendering method, apparatus, electronic device, and storage medium, which provides users with a rich visual experience, reduces visual fatigue, and improves user experience through diverse texture rendering methods.
[0004] In a first aspect, embodiments of this application provide a line rendering method, the method comprising:
[0005] Obtain the target region in the image to be processed;
[0006] Edge detection is performed on the target region to obtain the edge lines of the target region;
[0007] Obtain the target texture image that matches the image to be processed from one or more candidate texture images;
[0008] Based on the position of the edge lines in the image to be processed, the first texture lines corresponding to the edge lines are obtained from the target texture image;
[0009] Replace the edge lines with the first texture lines to render the edge lines and obtain the target image.
[0010] Secondly, embodiments of this application provide a line rendering apparatus, which includes: an acquisition unit and a processing unit;
[0011] The acquisition unit is used to acquire the target region in the image to be processed.
[0012] The processing unit is used to perform edge detection on the target area and obtain the edge lines of the target area;
[0013] Obtain the target texture image that matches the image to be processed from one or more candidate texture images;
[0014] Based on the position of the edge lines in the image to be processed, the first texture lines corresponding to the edge lines are obtained from the target texture image;
[0015] Replace the edge lines with the first texture lines to render the edge lines and obtain the target image.
[0016] Thirdly, embodiments of this application provide an electronic device, including: a processor and a memory, the processor being connected to the memory, the memory being used to store a computer program, and the processor being used to execute the computer program stored in the memory, so that the electronic device performs the method as described in the first aspect.
[0017] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program that causes a computer to perform the method as described in the first aspect.
[0018] Fifthly, embodiments of this application provide a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and is operable to cause the computer to perform the method as described in the first aspect.
[0019] Implementing the embodiments of this application has the following beneficial effects:
[0020] As can be seen, in this embodiment, the target region in the image to be processed is obtained; then, edge detection is performed on the target region to obtain the edge lines of the target region; a target texture image matching the image to be processed is obtained from one or more candidate texture images; then, according to the position of the edge lines in the image to be processed, a first texture line corresponding to the edge lines is obtained from the target texture image; finally, the first texture line is used to replace the edge lines to render the edge lines and obtain the target image. By selecting a target texture image that matches the image to be processed, instead of selecting a target texture image from a fixed number of texture images, a diverse range of texture rendering line methods are achieved, providing users with a rich visual experience, reducing visual fatigue, and thus improving the user experience. In addition, compared with the existing technology of judging the starting point of the line and then rendering it progressively, this solution uses the first texture line to replace the edge lines, which can be understood as using the first texture line to completely replace the edge lines at once, which speeds up the line rendering speed and reduces the complexity of line rendering. Attached Figure Description
[0021] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0022] Figure 1 A scene diagram illustrating line rendering provided in an embodiment of this application;
[0023] Figure 2 A flowchart illustrating a line rendering method provided in an embodiment of this application;
[0024] Figure 3 This is a schematic diagram illustrating the process of obtaining a target region from an image to be processed, as provided in an embodiment of this application.
[0025] Figure 4 This is a schematic diagram illustrating an edge detection method for a target region to obtain the edge lines of the target region, as provided in an embodiment of this application.
[0026] Figure 5 This is a schematic diagram illustrating a method for bidirectionally expanding an edge line to obtain a first line, as provided in an embodiment of this application.
[0027] Figure 6 This is a schematic diagram illustrating how a second texture line corresponding to the first line is obtained from a target texture image based on the position of the first line in the image to be processed, according to an embodiment of this application.
[0028] Figure 7 This is a schematic diagram illustrating how a first image is obtained by replacing edge lines with first texture lines, as provided in an embodiment of this application.
[0029] Figure 8 This is a schematic diagram illustrating how a target region in an image to be processed is superimposed onto the corresponding position of the target region in a first image to obtain a target image, as provided in an embodiment of this application.
[0030] Figure 9 A functional unit block diagram of a line rendering device provided in an embodiment of this application;
[0031] Figure 10 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0032] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0033] The terms "first," "second," "third," and "fourth," etc., used in the specification, claims, and drawings of this application are used to distinguish different objects, not to describe a specific order. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or apparatuses.
[0034] In this document, the term "embodiment" means that a particular feature, result, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0035] See Figure 1 , Figure 1 This is a schematic diagram of a line rendering scene provided in an embodiment of this application. The scene is applied to a line rendering device. The line rendering device is equipped with image or video editing software (not limited here), to render lines in an image.
[0036] For example, if the image or video editing software installed on the line rendering device has virtual function buttons corresponding to the line rendering method of this application, then when a user wants to perform line rendering on an image, they can do so by touching the virtual function buttons. Figure 1 As shown, after the line rendering device acquires the image to be processed, it will execute the line rendering method of this application to render the image to be processed and obtain the target image when it detects the user's touch operation on the virtual function button "Render". Optionally, when the line rendering device wants to render an image, it can load the image to be processed from local storage or obtain the image to be processed from other devices.
[0037] Specifically, the line rendering apparatus can acquire a target region in the image to be processed; then perform edge detection on the target region to obtain the edge lines of the target region; and acquire a target texture image that matches the image to be processed from one or more candidate texture images. It should be noted that the order in which the line rendering apparatus acquires the target region and the target texture image is not limited in this application; that is, it can be understood that the line rendering apparatus can acquire the target region first, and then acquire the target texture image; or, acquire the target texture image first, and then acquire the target region; or, acquire both the target texture image and the target region simultaneously.
[0038] Then, the line rendering device obtains the first texture line corresponding to the edge line from the target texture image based on the position of the edge line in the image to be processed; finally, the line rendering device replaces the edge line with the first texture line to render the edge line, thereby obtaining the target image.
[0039] As can be seen, in this embodiment, a target region in the image to be processed is obtained through a line rendering device; then, edge detection is performed on the target region to obtain the edge lines of the target region; a target texture image matching the image to be processed is obtained from one or more candidate texture images; then, based on the position of the edge lines in the image to be processed, a first texture line corresponding to the edge lines is obtained from the target texture image; finally, the first texture line is used to replace the edge lines to render the edge lines and obtain the target image. By selecting a target texture image that matches the image to be processed, instead of selecting one target texture image from a fixed number of texture images, a variety of line rendering methods are achieved, providing users with a rich visual experience, reducing visual fatigue, and thus improving the user experience. In addition, compared with the existing technology of determining the starting point of the line and then rendering progressively, this solution uses the first texture line to replace the edge lines, which can be understood as using the first texture line to completely replace the edge lines at once, thus speeding up the line rendering speed and reducing the complexity of line rendering.
[0040] See Figure 2 , Figure 2 This is a flowchart illustrating a line rendering method provided in an embodiment of this application. The method is applied to a line rendering device and includes, but is not limited to, steps 201-205:
[0041] 201: Obtain the target region in the image to be processed.
[0042] It should be noted that the line rendering device acquires the image to be processed before acquiring the target area. For example, the image to be processed can be a single frame image or a frame from a video. Optionally, the image to be processed can be an image stored locally by the line rendering device or a frame from a video stored locally, or it can be an image or a frame from a video obtained from another device; no limitation is made here. Furthermore, the line rendering device can be equipped with image or video editing software, and this image or video editing software can have virtual function buttons corresponding to the line rendering method of this application. When a user wants to perform line rendering on an image, they can achieve this by touching the virtual function buttons to obtain the target image.
[0043] Based on this, see Figure 3 , Figure 3 This is a schematic diagram illustrating how to obtain a target region from an image to be processed, as provided in an embodiment of this application. After obtaining... Figure 3 After displaying the image to be processed, when the user touches the virtual function button, target detection is performed on the image, for example, through a recurrent convolutional neural network, to obtain the target region. Figure 3 The target region is the woman in the image to be processed.
[0044] In an optional embodiment of this application, step 201 may include: firstly obtaining one or more candidate regions in the image to be processed; when the number of candidate regions is one, using the candidate region as the target region; when the number of candidate regions is multiple, using each candidate region as the target region simultaneously; or, selecting one candidate region from multiple candidate regions as the target region based on the area of each candidate region in the image to be processed.
[0045] For example, obtaining one or more candidate regions in an image to be processed can be achieved through object detection techniques, such as detection using a recurrent convolutional neural network.
[0046] Specifically, when only one candidate region is detected in the image to be processed, that candidate region is taken as the target region.
[0047] When multiple candidate regions are detected in the image to be processed, each candidate region is used as the target region at the same time. In other words, these multiple candidate regions can be rendered in parallel to obtain the target image.
[0048] When multiple candidate regions are detected in the image to be processed, a candidate region is selected as the target region based on the area of each candidate region in the image. That is, the candidate regions can be rendered sequentially according to their area size. For example, they can be rendered sequentially in descending order of area, such as first selecting the candidate region with the largest area as the target region, and then selecting the candidate region with the second largest area. Alternatively, in practical applications, they can also be rendered sequentially in ascending order of area, such as first selecting the candidate region with the smallest area as the target region, and then selecting the candidate region with the second smallest area. Therefore, this application does not limit the method of selecting candidate regions.
[0049] 202: Perform edge detection on the target area to obtain the edge lines of the target area.
[0050] In the embodiments of this application, the method for edge detection of the target region is not limited. For example, based on... Figure 3 The target area is shown in the image. Figure 4 , Figure 4 This application provides an embodiment of an embodiment for performing edge detection on a target region to obtain the edge lines of the target region. Figure 3 Edge detection is performed on the target area shown to obtain the edge lines corresponding to the target area.
[0051] 203: Obtain the target texture image that matches the image to be processed from one or more candidate texture images.
[0052] In an optional embodiment of this application, step 203 may specifically include: selecting a candidate texture image as a first texture image from one or more candidate texture images based on the usage popularity of one or more candidate texture images, wherein the first texture image is the texture image with the highest usage popularity; when a user's confirmation response for the first texture image is received, determining the first texture image as the target texture image; when a user's rejection response for the first texture image is received, receiving a second texture image uploaded by the user; and determining the second texture image as the target texture image.
[0053] For example, the most popular candidate texture image can be selected from one or more candidate texture images as the first texture image; then, when the line rendering device receives a confirmation response from the user for the first texture image, it uses the first texture image as the target texture image; if it receives a rejection response from the user for the first texture image, it receives a second texture image uploaded by the user and uses the second texture image as the target texture image, thereby satisfying the user's personalized needs and improving the user experience.
[0054] In an optional embodiment of this application, after obtaining a target texture image matching the image to be processed from one or more candidate texture images, the method may further include: scaling the target texture image according to the size of the image to be processed; and using the scaled target texture image as the target texture image again. It should be noted that scaling the target texture image to the same size as the image to be processed ensures that the size of the target texture image is greater than or equal to the size of the edge lines. This allows the first texture line corresponding to the edge lines to be found in the target texture image based on the position of the edge lines in the image to be processed, eliminating the need to re-determine whether a first texture line corresponding to the edge lines can be found in the unscaled target texture image. This speeds up line rendering and reduces its complexity.
[0055] 204: Based on the position of the edge line in the image to be processed, obtain the first texture line corresponding to the edge line from the target texture image.
[0056] In an optional embodiment of this application, step 204 may specifically include steps S1-S3:
[0057] S1: Expand the edge lines in both directions to obtain the first line.
[0058] It should be noted that in the embodiments of this application, step S1 can be: expanding each pixel on the edge line by n pixels to the left and m pixels to the right to obtain the first line, wherein m and n can be the same or different.
[0059] For example, based on Figure 4 The edge lines shown in the image are for reference. Figure 5 , Figure 5 This application provides a schematic diagram of a method for bidirectionally expanding edge lines to obtain a first line, as provided in an embodiment of the present application. Figure 4 The edges shown in the figure are expanded bidirectionally to obtain the first line.
[0060] S2: Based on the position of the first line in the image to be processed, obtain the second texture line corresponding to the first line from the target texture image.
[0061] It should be noted that image coordinate systems can be established separately for the image to be processed and the target texture image; this application is not limited to this. Then, based on the position of each pixel on the first line in the image to be processed, the position corresponding to the first line in the target texture image can be found, thereby obtaining the second texture line corresponding to the first line. For example, based on... Figure 5 The first line in the middle, see Figure 6 , Figure 6 This application provides an embodiment of a method for obtaining a second texture line corresponding to the first line from a target texture image based on the position of the first line in the image to be processed. A first image coordinate system is established in the image to be processed, and a second image coordinate system is established in the target texture image. Then, the coordinates of each pixel on the first line in the first image coordinate system are found. For clarity, Figure 6 The first image coordinate system only shows the coordinates of some pixels, namely A'(u1,v1), B'(u2,v2), and C'(u3,v3). Then, based on the coordinates of each pixel on the first line in the first image coordinate system, the corresponding coordinates of each pixel are found in the second image coordinate system, thus obtaining the second texture line corresponding to the first line. Similarly, for clear visibility... Figure 6 The second image coordinate system also only shows the coordinates corresponding to some pixels in the first image coordinate system, namely A(u1,v1), B(u2,v2) and C(u3,v3). Among them, A(u1,v1) corresponds to A'(u1,v1), B(u2,v2) corresponds to B'(u2,v2), and C(u3,v3) corresponds to C'(u3,v3).
[0062] S3: Define the second texture line as the first texture line.
[0063] In one optional embodiment of this application, step S2 may include steps A1-A3:
[0064] A1: Retain all pixels in the first line that correspond to the edge line, as well as the pixels to the left of all those pixels, to obtain the second line.
[0065] In other words, if each pixel on the edge line is expanded to the left by n pixels and to the right by m pixels to obtain the first line, then retaining all the pixels in the first line that correspond to the edge line, as well as the pixels to the left of all those pixels, can be understood as retaining all the pixels in the first line that correspond to the edge line, as well as the n pixels to the left of all those pixels, and then obtaining the second line.
[0066] A2: Based on the position of the second line in the image to be processed, obtain the fourth texture line corresponding to the second line from the target texture image.
[0067] It should be noted that the implementation principle of step A2 is similar to that of step S2, and will not be repeated here.
[0068] A3: Designate the fourth texture line as the second texture line.
[0069] In an optional embodiment of this application, step 204 may further include steps B1-B3:
[0070] B1: Expand the edge lines in one direction to obtain the third line.
[0071] The unidirectional expansion of the edge lines can be understood as expanding each pixel on the edge lines by P pixels to the left.
[0072] B2: Based on the position of the third line in the image to be processed, obtain the fifth texture line corresponding to the third line from the target texture image.
[0073] It should be noted that the implementation principle of step B2 is similar to that of step S2, and will not be repeated here.
[0074] B3: Designate the fifth texture line as the first texture line.
[0075] 205: Replace the edge lines with the first texture lines to render the edge lines and obtain the target image.
[0076] In an optional embodiment of this application, when based on the method of steps S1-S3, step 205 may include: replacing edge lines with first texture lines to obtain a first image; and superimposing the target region in the image to be processed onto the corresponding position of the target region in the first image to obtain a target image.
[0077] For example, replacing edge lines with the first texture line to obtain the first image can be understood as replacing the edge lines completely and once with the first texture line to obtain the first image, thus speeding up line rendering. Based on the first texture line shown in Figure 6, see [reference needed]. Figure 7 , Figure 7 This is a schematic diagram of a method to obtain a first image by replacing edge lines with a first texture line according to an embodiment of this application. The first image is obtained by replacing the edge lines with the first texture line in one complete step.
[0078] Then, the target region in the image to be processed is superimposed onto the corresponding position of the target region in the first image, avoiding the situation where the target region is obscured by the first texture lines, thus presenting a better line rendering effect. Based on Figure 7 The first image shown in the image is referenced. Figure 8 , Figure 8 This is a schematic diagram of an embodiment of the present application, which shows how to superimpose a target region in an image to be processed onto the corresponding position of the target region in a first image to obtain a target image. The target region in the image to be processed, i.e., the woman in the image to be processed, is superimposed onto the corresponding position of the target region in the first image to obtain the target image.
[0079] It should be noted that when based on steps S1-S3, i.e., bidirectional dilation of the edge lines is performed to obtain the first line, and then based on the position of the first line in the image to be processed, the second texture line corresponding to the first line is obtained from the target texture image. After the second texture line is determined as the first texture line, the edge lines are replaced completely with the first texture line to obtain the first image, which speeds up the line rendering process. Then, the target area in the image to be processed is superimposed on the corresponding position of the target area in the first image, avoiding the situation where the target area is occluded by the first texture line, so as to present a better line rendering effect.
[0080] In an optional embodiment of this application, when based on the method of steps S1-S3, step 205 may further include: retaining all pixels in the first texture line that correspond to the edge line, as well as the pixels to the left of all the pixels, to obtain a third texture line; and replacing the edge line with the third texture line to obtain the target image.
[0081] It should be noted that when based on steps S1-S3, i.e., bidirectional dilation is performed on the edge lines to obtain the first line, and then based on the position of the first line in the image to be processed, the second texture line corresponding to the first line is obtained from the target texture image. After the second texture line is determined as the first texture line, all pixels in the first texture line corresponding to the edge line, as well as the pixels to the left of all these pixels, are retained. This can be understood as cropping the first texture line to obtain the third texture line. The third texture line is used to replace the edge line to obtain the target image. This method of cropping the first texture line before replacing the edge line avoids the situation where the target area is obscured by the uncropped first texture line, thus presenting a better line rendering effect.
[0082] As can be seen, in this embodiment, the target region in the image to be processed is obtained; then, edge detection is performed on the target region to obtain the edge lines of the target region; from one or more candidate texture images, a target texture image matching the image to be processed is obtained; then, according to the position of the edge lines in the image to be processed, a first texture line corresponding to the edge lines is obtained from the target texture image; finally, the first texture line is used to replace the edge lines to render the edge lines and obtain the target image. By selecting a target texture image that matches the image to be processed, instead of selecting a target texture image from a fixed number of texture images, a diverse range of texture rendering line methods is achieved, providing users with a rich visual experience, reducing visual fatigue, and thus improving the user experience. In addition, compared with the existing technology of determining the starting point of the line and then rendering progressively, this solution uses the first texture line to replace the edge lines, which can be understood as using the first texture line to replace the edge lines once and completely, thus speeding up the line rendering speed and reducing the complexity of line rendering.
[0083] See Figure 9 , Figure 9 This is a functional unit block diagram of a line rendering device provided in an embodiment of this application. The line rendering device 900 includes: an acquisition unit 901 and a processing unit 902;
[0084] Acquisition unit 901 is used to acquire the target region in the image to be processed;
[0085] Processing unit 902 is used to perform edge detection on the target area to obtain the edge lines of the target area;
[0086] Obtain the target texture image that matches the image to be processed from one or more candidate texture images;
[0087] Based on the position of the edge lines in the image to be processed, the first texture lines corresponding to the edge lines are obtained from the target texture image;
[0088] Replace the edge lines with the first texture lines to render the edge lines and obtain the target image.
[0089] In one embodiment of this application, the processing unit 902 is specifically configured to: acquire a target region in an image to be processed.
[0090] Determine the hazard level of the target location based on R;
[0091] Based on the current abnormal behavior of R individuals and the danger level of the target location, generate a warning voice message.
[0092] In one embodiment of this application, the acquisition unit 901, in sending a warning voice to an audio device, is specifically used for:
[0093] Obtain one or more candidate regions from the image to be processed;
[0094] When there is only one candidate region, the candidate region is used as the target region.
[0095] When there are multiple candidate regions, each candidate region is used as the target region simultaneously; or, based on the area of each candidate region in the image to be processed, one candidate region is selected as the target region from multiple candidate regions.
[0096] In one embodiment of this application, in obtaining a first texture line corresponding to the edge line from a target texture image based on the position of the edge line in the image to be processed, the processing unit 902 is specifically configured to:
[0097] The first line is obtained by bidirectional expansion of the edge lines;
[0098] Based on the position of the first line in the image to be processed, obtain the second texture line corresponding to the first line from the target texture image;
[0099] The second texture line is designated as the first texture line.
[0100] In one embodiment of this application, in order to render the edge lines by replacing them with first texture lines to obtain a target image, the processing unit 902 is specifically used for:
[0101] Replace the edge lines with the first texture lines to obtain the first image;
[0102] The target region in the image to be processed is superimposed onto the corresponding position of the target region in the first image to obtain the target image.
[0103] In one embodiment of this application, in order to render the edge lines by replacing them with first texture lines to obtain a target image, the processing unit 902 is specifically used for:
[0104] The third texture line is obtained by preserving all pixels corresponding to the edge lines in the first texture line, as well as the pixels to the left of all those pixels.
[0105] Replace the edge lines with third texture lines to obtain the target image.
[0106] In one embodiment of this application, in obtaining a second texture line corresponding to the first line from a target texture image based on the position of the first line in the image to be processed, the processing unit 902 is specifically configured to:
[0107] The second line is obtained by retaining all pixels in the first line that correspond to the edge line, as well as the pixels to the left of all those pixels.
[0108] Based on the position of the second line in the image to be processed, obtain the fourth texture line corresponding to the second line from the target texture image;
[0109] The fourth texture line is designated as the second texture line.
[0110] In one embodiment of this application, in obtaining a first texture line corresponding to the edge line from a target texture image based on the position of the edge line in the image to be processed, the processing unit 902 is specifically configured to:
[0111] By unidirectionally expanding the edge lines, a third line is obtained;
[0112] Based on the position of the third line in the image to be processed, obtain the fifth texture line corresponding to the third line from the target texture image.
[0113] The fifth texture line is designated as the first texture line.
[0114] In one embodiment of this application, in obtaining a target texture image that matches the image to be processed from one or more candidate texture images, the processing unit 902 is specifically configured to:
[0115] Based on the usage popularity of one or more candidate texture images, select one candidate texture image as the first texture image from one or more candidate texture images;
[0116] When a confirmation response for the first texture image is received from the user, the first texture image is identified as the target texture image.
[0117] When a rejection response for the first texture image is received from the user terminal, the second texture image is received from the user terminal.
[0118] The second texture image is determined as the target texture image.
[0119] In one embodiment of this application, after obtaining a target texture image that matches the image to be processed from one or more candidate texture images, the processing unit 902 is specifically configured to:
[0120] The target texture image is scaled according to the size of the image to be processed;
[0121] The scaled target texture image is then used as the target texture image again.
[0122] See Figure 10 , Figure 10 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 10 As shown, the electronic device 1000 includes a transceiver 1001, a processor 1002, and a memory 1003. They are connected to each other via a bus 1004. The memory 1003 is used to store computer programs and data, and can transfer data stored in the memory 1003 to the processor 1002.
[0123] Processor 1002 is used to read computer programs from memory 1003 and perform the following operations:
[0124] Control transceiver 1001 to acquire the target region in the image to be processed;
[0125] Edge detection is performed on the target region to obtain the edge lines of the target region;
[0126] Obtain the target texture image that matches the image to be processed from one or more candidate texture images;
[0127] Based on the position of the edge lines in the image to be processed, the first texture lines corresponding to the edge lines are obtained from the target texture image;
[0128] Replace the edge lines with the first texture lines to render the edge lines and obtain the target image.
[0129] In one embodiment of this application, the transceiver 1001 is specifically configured to perform the following steps in acquiring a target region in an image to be processed:
[0130] Obtain one or more candidate regions from the image to be processed;
[0131] When there is only one candidate region, the candidate region is used as the target region.
[0132] When there are multiple candidate regions, each candidate region is used as the target region simultaneously; or, based on the area of each candidate region in the image to be processed, one candidate region is selected as the target region from multiple candidate regions.
[0133] In one embodiment of this application, in obtaining a first texture line corresponding to the edge line from a target texture image based on the position of the edge line in the image to be processed, the processor 1002 is specifically configured to perform the following steps:
[0134] The first line is obtained by bidirectional expansion of the edge lines;
[0135] Based on the position of the first line in the image to be processed, obtain the second texture line corresponding to the first line from the target texture image;
[0136] The second texture line is designated as the first texture line.
[0137] In one embodiment of this application, in order to render the edge lines by replacing them with first texture lines to obtain a target image, the processor 1002 is specifically configured to perform the following steps:
[0138] Replace the edge lines with the first texture lines to obtain the first image;
[0139] The target region in the image to be processed is superimposed onto the corresponding position of the target region in the first image to obtain the target image.
[0140] In one embodiment of this application, in order to render the edge lines by replacing them with first texture lines to obtain a target image, the processor 1002 is specifically configured to perform the following steps:
[0141] The third texture line is obtained by preserving all pixels corresponding to the edge lines in the first texture line, as well as the pixels to the left of all those pixels.
[0142] Replace the edge lines with third texture lines to obtain the target image.
[0143] In one embodiment of this application, in obtaining a second texture line corresponding to the first line from a target texture image based on the position of the first line in the image to be processed, the processor 1002 is specifically configured to perform the following steps:
[0144] The second line is obtained by retaining all pixels in the first line that correspond to the edge line, as well as the pixels to the left of all those pixels.
[0145] Based on the position of the second line in the image to be processed, obtain the fourth texture line corresponding to the second line from the target texture image;
[0146] The fourth texture line is designated as the second texture line.
[0147] In one embodiment of this application, in obtaining a first texture line corresponding to the edge line from a target texture image based on the position of the edge line in the image to be processed, the processor 1002 is specifically configured to perform the following steps:
[0148] By unidirectionally expanding the edge lines, a third line is obtained;
[0149] Based on the position of the third line in the image to be processed, obtain the fifth texture line corresponding to the third line from the target texture image.
[0150] The fifth texture line is designated as the first texture line.
[0151] In one embodiment of this application, in obtaining a target texture image that matches the image to be processed from one or more candidate texture images, the processor 1002 is specifically configured to perform the following steps:
[0152] Based on the usage popularity of one or more candidate texture images, select one candidate texture image as the first texture image from one or more candidate texture images;
[0153] When a confirmation response for the first texture image is received from the user, the first texture image is identified as the target texture image.
[0154] When a rejection response for the first texture image is received from the user terminal, the second texture image is received from the user terminal.
[0155] The second texture image is determined as the target texture image.
[0156] In one embodiment of this application, after obtaining a target texture image that matches the image to be processed from one or more candidate texture images, the processor 1002 is specifically configured to perform the following steps:
[0157] The target texture image is scaled according to the size of the image to be processed;
[0158] The scaled target texture image is then used as the target texture image again.
[0159] Specifically, the transceiver 1001 described above can be... Figure 9 The acquisition unit 901 of the line rendering apparatus 900 in the embodiment, the processor 1002 can be Figure 9 The processing unit 902 of the line rendering apparatus 900 in the embodiment.
[0160] It should be understood that the electronic devices mentioned in this application may include smartphones (such as Android phones, iOS phones, Windows Phones, etc.), tablet computers, PDAs, laptops, mobile internet devices (MIDs), or wearable devices. The above-mentioned electronic devices are merely examples and not exhaustive, and include, but are not limited to, the electronic devices described above. In practical applications, the above-mentioned electronic devices may also include: intelligent in-vehicle terminals, computer equipment, etc.
[0161] This application also provides a computer-readable storage medium storing a computer program that is executed by a processor to implement some or all of the steps of any of the line rendering methods described in the above method embodiments.
[0162] This application also provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program operable to cause a computer to perform some or all of the steps of any of the line rendering methods described in the above method embodiments.
[0163] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily essential to this application.
[0164] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.
[0165] In the several embodiments provided in this application, it should be understood that the disclosed apparatus can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical or other forms.
[0166] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0167] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software program module.
[0168] If the integrated unit is implemented as a software program module and sold or used as an independent product, it can be stored in a computer-readable storage device (CMD). Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a memory and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned memory includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.
[0169] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, which may include: flash drive, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0170] The embodiments of this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The description of the above embodiments is only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A line rendering method, characterized in that, The method includes: Obtain the target region in the image to be processed; Edge detection is performed on the target region to obtain the edge lines of the target region; Obtain a target texture image that matches the image to be processed from one or more candidate texture images; Based on the position of the edge line in the image to be processed, the edge line is expanded in one direction or in two directions, and a first texture line corresponding to the expanded edge line is obtained from the target texture image. The edge lines are replaced with the first texture lines to render the edge lines and obtain the target image.
2. The method according to claim 1, characterized in that, The process of obtaining the target region in the image to be processed includes: Obtain one or more candidate regions from the image to be processed; When the number of candidate regions is one, the candidate region is taken as the target region; When there are multiple candidate regions, each candidate region is simultaneously used as the target region; or, based on the area of each candidate region in the image to be processed, one candidate region is selected from the multiple candidate regions as the target region.
3. The method according to claim 1 or 2, characterized in that, The step of obtaining a first texture line corresponding to the edge line from the target texture image based on the position of the edge line in the image to be processed includes: The edge lines are expanded bidirectionally to obtain the first line; Based on the position of the first line in the image to be processed, a second texture line corresponding to the first line is obtained from the target texture image; The second texture line is identified as the first texture line.
4. The method according to claim 3, characterized in that, The step of replacing the edge lines with the first texture lines to render the edge lines and obtain the target image includes: The first image is obtained by replacing the edge lines with the first texture lines; The target region in the image to be processed is superimposed onto the corresponding position of the target region in the first image to obtain the target image.
5. The method according to claim 3, characterized in that, The step of replacing the edge lines with the first texture lines to render the edge lines and obtain the target image includes: The third texture line is obtained by retaining all pixels in the first texture line that correspond to the edge line, as well as the pixels to the left of all the pixels. The target image is obtained by replacing the edge lines with the third texture lines.
6. The method according to claim 3, characterized in that, The step of obtaining a second texture line corresponding to the first line from the target texture image based on the position of the first line in the image to be processed includes: The second line is obtained by retaining all pixels in the first line that correspond to the edge line, as well as the pixels to the left of all the pixels. Based on the position of the second line in the image to be processed, a fourth texture line corresponding to the second line is obtained from the target texture image; The fourth texture line is identified as the second texture line.
7. The method according to claim 1 or 2, characterized in that, The step of obtaining a first texture line corresponding to the edge line from the target texture image based on the position of the edge line in the image to be processed includes: The edge lines are expanded in one direction to obtain a third line; Based on the position of the third line in the image to be processed, a fifth texture line corresponding to the third line is obtained from the target texture image. The fifth texture line is identified as the first texture line.
8. The method according to claim 1, characterized in that, The step of obtaining a target texture image that matches the image to be processed from one or more candidate texture images includes: Based on the usage popularity of the one or more candidate texture images, a candidate texture image is selected from the one or more candidate texture images as the first texture image, wherein the first texture image is the texture image with the highest usage popularity; When a user's confirmation response for the first texture image is received, the first texture image is identified as the target texture image; When a rejection response from the user for the first texture image is received, the second texture image uploaded by the user is received; The second texture image is determined as the target texture image.
9. The method according to claim 1, characterized in that, After obtaining a target texture image matching the image to be processed from one or more candidate texture images, the method further includes: The target texture image is scaled according to the size of the image to be processed; The scaled target texture image is then used as the target texture image again.
10. A line rendering device, characterized in that, The device includes: an acquisition unit and a processing unit; The acquisition unit is used to acquire the target region in the image to be processed; The processing unit is used to perform edge detection on the target region to obtain the edge lines of the target region; Obtain a target texture image that matches the image to be processed from one or more candidate texture images; Based on the position of the edge line in the image to be processed, the edge line is expanded in one direction or in two directions, and a first texture line corresponding to the expanded edge line is obtained from the target texture image. The edge lines are replaced with the first texture lines to render the edge lines and obtain the target image.
11. An electronic device, characterized in that, include: A processor and a memory, the processor being connected to the memory, the memory being used to store a computer program, and the processor being used to execute the computer program stored in the memory to cause the electronic device to perform the method as described in any one of claims 1-9.
12. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that is executed by a processor to implement the method as described in any one of claims 1-9.
Citation Information
Patent Citations
Line rendering method and device, electronic equipment and storage medium
CN117765103A
