Curve stroking method and device, electronic equipment and storage medium

By performing different processing on the stroke curve, images of the two curves are generated, and the normal distances between the curves are ensured equal in the stacking setting, the high power consumption and large memory overhead of the curve stroke method in the prior art are solved, and efficient image processing and equal distance stroke effect are achieved.

CN120163897APending Publication Date: 2025-06-17BEIJING XIAOMI MOBILE SOFTWARE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311723185.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-12-14
Publication Date
2025-06-17

AI Technical Summary

Technical Problem

In the prior art, the curve stroke method has problems with large image processing power consumption and memory overhead.

Method used

By performing different processing on the stroke curve to be performed, two images have the first curve and the second curve, and in the target image, the first image and the second image stacking setting, it is ensured that the stroke curve to be stroked is located between the first curve and the second curve, and that the normal distance between the two curves is equal, thereby obtaining the stroke result for the stroke curve to be stroked.

Benefits of technology

It realizes reducing image processing power consumption and memory overhead, while obtaining equal distance stroke results, avoiding adding too many maps.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120163897A_ABST
    Figure CN120163897A_ABST
Patent Text Reader

Abstract

The invention relates to a curve stroking method and device, electronic equipment and a storage medium. The curve stroking method comprises the following steps: acquiring a to-be-stroked curve in a target image; the to-be-stroked curve is processed to obtain a first image, and the first image is provided with a first curve; the to-be-stroked curve is processed to obtain a second image, and the second image is provided with a second curve different from the first curve; wherein under the condition that the target image, the first image and the second image are stacked and the center of the target image, the center of the first image and the center of the second image coincide, the curve to be stroked is located between the first curve and the second curve, and the normal distances of different positions between the first curve and the second curve are equal; and based on the first image and the second image, obtaining a stroking result for the to-be-stroked curve. According to the embodiment of the invention, image processing power consumption and memory overhead can be reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of image interfaces, and in particular, to a curve stroking method and apparatus, an electronic device, and a storage medium. Background Art

[0002] With the continuous development of image processing technology, the image processing operations that can be provided on electronic devices are becoming increasingly rich, and stroking is a common image processing method. In the related art, the stroking of a curve cannot be represented by another curve. Therefore, if a fixed-width stroking is implemented for a curve, usually two methods, namely, the Standard Difference Filter (SDF) or the Tessellation method, are used for curve stroking. However, both of these two methods have the problems of high image processing power consumption and large memory overhead. Summary of the Invention

[0003] To overcome the problems in the related art, the present disclosure provides a curve stroking method and apparatus, an electronic device, and a storage medium, which can reduce the image processing power consumption and memory overhead.

[0004] According to a first aspect of an embodiment of the present disclosure, a curve stroking method is provided, including:

[0005] Obtaining a curve to be stroked in a target image;

[0006] Processing the curve to be stroked to obtain a first image, where the first image has a first curve;

[0007] Processing the curve to be stroked to obtain a second image, where the second image has a second curve different from the first curve; wherein, when the target image, the first image, and the second image are stacked and the centers of the target image, the first image, and the second image coincide, the curve to be stroked is located between the first curve and the second curve, and the normal distances at different positions between the first curve and the second curve are equal;

[0008] Based on the first image and the second image, obtaining a stroking result for the curve to be stroked.

[0009] In some embodiments, the processing the curve to be stroked to obtain a first image includes:

[0010] Performing an expanding and translating process on the smallest rectangle covering the curve to be stroked to obtain an expanded rectangle; wherein, the distances by which each side of the smallest rectangle covering the curve to be stroked is translated outward are equal;

[0011] Process the enlarged rectangle to obtain the first image.

[0012] In some embodiments, the processing the enlarged rectangle to obtain the first image includes:

[0013] Based on the curvature radius corresponding to the curve to be stroked, the stroke width of the curve to be stroked, and a preset enlargement weight, obtain the curvature radius corresponding to the first curve;

[0014] Based on the curvature radius corresponding to the first curve and the enlarged rectangle, obtain the first image.

[0015] In some embodiments, the processing the curve to be stroked to obtain the second image includes:

[0016] Perform a reduction and translation process on the smallest rectangle covering the curve to be stroked to obtain a reduced rectangle; wherein, the distance of inward translation of each rectangle side in the smallest rectangle covering the curve to be stroked is equal;

[0017] Process the reduced rectangle to obtain the second image.

[0018] In some embodiments, the processing the reduced rectangle to obtain the second image includes:

[0019] Based on the curvature radius corresponding to the curve to be stroked, the stroke width of the curve to be stroked, and a preset reduction weight, obtain the curvature radius corresponding to the second curve;

[0020] Based on the curvature radius corresponding to the second curve and the reduced rectangle, obtain the second image.

[0021] In some embodiments, the obtaining the stroke result for the curve to be stroked based on the first image and the second image includes:

[0022] Sample the first image and the second image respectively to obtain a sampled image of the first image and a sampled image of the second image;

[0023] Based on the sampled image of the first image and the sampled image of the second image, obtain the stroke result for the curve to be stroked.

[0024] In some embodiments, the sampling the first image and the second image respectively to obtain a sampled image of the first image and a sampled image of the second image includes:

[0025] Based on the color information of the first image and the color information of the target image, obtain the sampled image of the first image;

[0026] Based on the color information of the second image and the color information of the target image, a sampled image of the second image is obtained.

[0027] In some embodiments, based on the sampled image of the first image and the sampled image of the second image, obtaining a stroke result for the curve to be stroked, includes:

[0028] Based on the difference between a preset coefficient and the color information of the sampled image of the second image, difference color information is obtained;

[0029] Based on the product between the difference color information and the color information of the sampled image of the first image, the stroke result is obtained.

[0030] According to a second aspect of the embodiments of the present disclosure, there is provided a curve stroking device, characterized by including:

[0031] An acquisition module, configured to acquire a curve to be stroked in a target image;

[0032] A first processing module, configured to process the curve to be stroked to obtain a first image, the first image having a first curve;

[0033] A second processing module, configured to process the curve to be stroked to obtain a second image, the second image having a second curve different from the first curve; wherein, when the target image, the first image and the second image are stacked, and the centers of the target image, the first image and the second image coincide, the curve to be stroked is located between the first curve and the second curve, and the normal distances at different positions between the first curve and the second curve are equal;

[0034] An image obtaining module, configured to obtain a stroke result for the curve to be stroked based on the first image and the second image.

[0035] According to a third aspect of the embodiments of the present disclosure, there is provided an electronic device, at least including:

[0036] A processor;

[0037] A memory for storing processor-executable instructions;

[0038] Wherein, the processor is configured to execute the curve stroking method as described in the first aspect above.

[0039] According to a fourth aspect of the embodiments of the present disclosure, there is provided a storage medium, including:

[0040] When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device can execute the curve tracing method in the first aspect as described above.

[0041] The technical solutions provided by the embodiments of the present disclosure may include the following beneficial effects:

[0042] In the embodiments of the present disclosure, by performing different processes on the curve to be traced, a first image with a first curve and a second image with a second curve can be obtained. Moreover, the curve to be traced is located between the first curve and the second curve, and the normal distances at different positions between the first curve and the second curve are equal. Therefore, the embodiments of the present disclosure can not only obtain an equidistant tracing result for the curve to be traced based on the first curve of the first image and the second curve of the second image, but also reduce the image processing power consumption and memory overhead without adding too many texture maps.

[0043] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, and cannot limit the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] The drawings herein are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present disclosure and used together with the specification to explain the principles of the present disclosure.

[0045] Figure 1 is a schematic diagram of tracing a circle shown according to an exemplary embodiment.

[0046] Figure 2 is a schematic diagram of the constant normal distance between curves shown according to an exemplary embodiment.

[0047] Figure 3 is a schematic diagram of tracing a scaled curve shown according to an exemplary embodiment.

[0048] Figure 4 is a schematic diagram of a curve tracing method shown according to an exemplary embodiment.

[0049] Figure 5 is a schematic diagram of data processing in a target image shown according to an exemplary embodiment.

[0050] Figure 6 is a schematic diagram of a first image and a second image shown according to an exemplary embodiment Figure 1 .

[0051] Figure 7 is a schematic diagram of a first image and a second image shown according to an exemplary embodiment Figure 2 .

[0052] Figure 8It is a schematic diagram of a stroke result shown according to an exemplary embodiment.

[0053] Figure 9 It is a schematic diagram of a first curve and a second curve shown according to an exemplary embodiment.

[0054] Figure 10A It is a schematic diagram of using synthetic digital image processing to process an image shown according to an exemplary embodiment.

[0055] Figure 10B It is a schematic diagram of using synthetic digital image processing to process an image shown according to an exemplary embodiment.

[0056] Figure 10C It is a schematic diagram of using synthetic digital image processing to process an image shown according to an exemplary embodiment.

[0057] Figure 11 It is a schematic structural diagram of a curve stroking device shown according to an exemplary embodiment.

[0058] Figure 12 It is a schematic structural diagram of an electronic device shown according to an exemplary embodiment. Detailed implementation manners

[0059] Here, the exemplary embodiments will be described in detail, and the examples are shown in the drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementation manners described in the following exemplary embodiments do not represent all implementation manners consistent with the present disclosure. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.

[0060] In the related art, Figure 1 It is a schematic diagram of stroking a circle shown according to an exemplary embodiment. As Figure 1 shown, for a circle, the stroke of the circle is still a circle, and the stroke of the circle can be obtained by scaling the circle based on the unchanged center o.

[0061] However, since the stroke of a curve needs to ensure that the normal distance between curves is always equal. Figure 2 A schematic diagram of the normal distance between curves being always equal shown according to an exemplary embodiment. As Figure 2 shown, the normal distances d from different points on the first curve to the second curve are equal. Therefore, if the stroke method of a circle is used to stroke a curve, Figure 3 It is a schematic diagram of stroking a curve scaling shown according to an exemplary embodiment. As Figure 3As shown, based on the fact that the center of the circular arc corresponding to the curve remains unchanged, when scaling the curve, there will be a problem that the normal distances between the two curves are not always equal, resulting in an incorrect stroke being unable to be obtained.

[0062] In the related art, there are problems of high image processing power consumption and large memory overhead when using two methods, namely the Standard difference filter (SDF) or the Tessellation method, for curve stroke.

[0063] Based on this, an embodiment of the present disclosure proposes a method for curve stroke. By adjusting the curve to be stroked, the stroke result for the curve to be stroked can be obtained, which can reduce the power consumption and memory overhead of image processing.

[0064] Figure 4 It is a schematic diagram of a method for curve stroke shown according to an exemplary embodiment. As Figure 4 shown, when an electronic device executes this method for curve stroke, it at least includes the following steps:

[0065] S101. Obtain the curve to be stroked in the target image;

[0066] S102. Process the curve to be stroked to obtain a first image, and the first image has a first curve;

[0067] S103. Process the curve to be stroked to obtain a second image, and the second image has a second curve different from the first curve; wherein, when the target image, the first image, and the second image are stacked, and the centers of the target image, the first image, and the second image coincide, the curve to be stroked is located between the first curve and the second curve, and the normal distances at different positions between the first curve and the second curve are equal;

[0068] S104. Based on the first image and the second image, obtain the stroke result for the curve to be stroked.

[0069] In the embodiment of the present disclosure, the method for curve stroke is applicable to the stroke scenario of image processing. Exemplarily, in the processing of a human image, the human image can be used as the target image, and the curve in the human image can be used as the curve to be stroked. Through the curve stroke of the embodiment of the present disclosure, the stroke result can be displayed in the human image. Another example is that in the processing of a letter image, the letter image can be used as the target image, and the curve in the letter image can be used as the curve to be stroked. Through the curve stroke of the embodiment of the present disclosure, the stroke result can be displayed in the processing of the letter image.

[0070] In step S101, the target image can be any to-be-processed image that needs to be stroked. The curve to be stroked in the target image can be specified by the user or obtained through detection.

[0071] Exemplarily, obtaining the curve to be stroked in the target image may include: in response to the user's curve stroking operation, obtaining the curve to be stroked in the target image, and may also include: detecting the target image and using the detected curve as the curve to be stroked.

[0072] It should be noted that the curve to be stroked can be a Bezier curve. The Bezier curve can be a smooth and continuous curve defined by a set of discrete control points through a formula. Exemplarily, the Bezier curve includes but is not limited to the curve corresponding to a smooth rounded corner, the curve corresponding to a super-ellipse, etc., and the embodiments of the present disclosure do not limit this.

[0073] In the embodiments of the present disclosure, as Figure 5 shown, in the process of obtaining the curve to be stroked in the target image, the Alpha channel value in the target image can be retained, the Alpha channel value inside the curve to be stroked is set to 1, and the Alpha channel value outside the curve to be stroked is set to 0, and anti-aliasing is achieved through Alpha transition.

[0074] In steps S102 and S103, when the target image, the first image, and the second image are stacked and the centers of the target image, the first image, and the second image coincide, the curve to be stroked is located between the first curve in the first image and the second curve in the second image, and the normal distances at different positions between the first curve and the second curve are equal. That is to say, by performing different processes on the curve to be stroked in the target image, it is possible to ensure that the normal distance between the first curve and the second curve is constant, and then a better stroking result for the curve to be stroked can be obtained based on the first image and the second image.

[0075] The above process of processing the curve to be stroked to obtain the first image includes: processing the curve to be stroked in the target image to obtain a first image with a first curve. Here, processing the curve to be stroked includes but is not limited to processing the smallest rectangle covering the curve to be stroked based on a shrinking translation algorithm to obtain a first image with a first curve; or processing the smallest rectangle covering the curve to be stroked through an expanding translation algorithm to obtain a first image with a first curve.

[0076] Processing the above-mentioned stroke curve to obtain a second image includes: processing the stroke curve in the target image to obtain a second image with a second curve. Here, processing the stroke curve includes, but is not limited to, processing the smallest rectangle covering the stroke curve through a shrinking translation algorithm to obtain a second image with a second curve; or processing the smallest rectangle covering the stroke curve through an expanding translation algorithm to obtain a second image with a second curve.

[0077] It should be noted that in the case where the first curve is obtained by processing through a shrinking translation algorithm, correspondingly, the second curve is obtained by processing through an expanding translation algorithm; or in the case where the first curve is obtained by processing through an expanding translation algorithm, correspondingly, the second curve is obtained by processing through a shrinking translation algorithm.

[0078] In the embodiments of the present disclosure, the bending direction of the first curve in the first image is the same as the bending direction of the stroke curve; the bending direction of the second curve in the second image is the same as the bending direction of the stroke curve. And when the stroke curve is a Bezier curve, both the first curve and the second curve are Bezier curves.

[0079] It should be noted that the brightness and darkness of the first image and the second image are different.

[0080] In step S103, obtaining the stroke result for the stroke curve based on the first image and the second image at least includes respectively sampling the color information of the first image and the color information of the second image and performing synthetic digital image processing to obtain the stroke result of the stroke curve.

[0081] In the embodiments of the present disclosure, Figure 6 is a schematic diagram of the first image and the second image shown according to an exemplary embodiment Figure 1 . Figure 7 is a schematic diagram of the first image and the second image shown according to an exemplary embodiment Figure 2 . Figure 8 is a schematic diagram of a stroke result shown according to an exemplary embodiment. As Figure 6 , Figure 7 and Figure 8 shown, the brightness and darkness of the first image 12 and the second image 11 are different, and based on the first image 12 and the second image 11, the stroke result in Figure 8 can be obtained.

[0082] In the embodiments of the present disclosure, by performing different processes on the curve to be stroked, a first image with a first curve and a second image with a second curve can be obtained. Moreover, the curve to be stroked is located between the first curve and the second curve, and the normal distances at different positions between the first curve and the second curve are equal. Therefore, in the embodiments of the present disclosure, not only can an equidistant stroked result for the curve to be stroked be obtained based on the first image and the second image, but also the addition of excessive textures can be avoided, reducing the image processing power consumption and memory overhead.

[0083] In some embodiments, the process of processing the curve to be stroked to obtain the first image includes:

[0084] Performing an enlarged translation process on the smallest rectangle covering the curve to be stroked to obtain an enlarged rectangle; wherein, the distances by which each side of the smallest rectangle covering the curve to be stroked is translated outward are equal;

[0085] Processing the enlarged rectangle to obtain the first image.

[0086] In the embodiments of the present disclosure, performing an enlarged translation process on the smallest rectangle covering the curve to be stroked to obtain an enlarged rectangle includes: performing an enlarged translation process on the smallest rectangle covering the curve to be stroked based on a first translation distance to obtain an enlarged rectangle. Here, the first translation distance can be set according to actual requirements, and the embodiments of the present disclosure do not limit this.

[0087] Exemplarily, the enlarged rectangle can be obtained through formulas (1) and (2).

[0088] out = rect.makeOutset(intx, inty) (1)

[0089] x = y = strokeWidth * 0.5 (2)

[0090] Wherein, out represents the enlarged rectangle; strokeWidth represents the stroke width; rect represents the smallest rectangle covering the curve to be stroked; makeOutset(intx, inty) represents that two adjacent sides of the smallest rectangle covering the curve to be stroked are respectively translated outward by the first translation distances x and y.

[0091] In the embodiments of the present disclosure, after obtaining the enlarged rectangle, the enlarged rectangle can be processed to obtain the first image. Here, in some embodiments, processing the enlarged rectangle to obtain the first image may include performing image matching on the enlarged rectangle to obtain the first image. In other embodiments, the process of processing the enlarged rectangle to obtain the first image includes:

[0092] Based on the curvature radius corresponding to the curve to be stroked, the stroke width of the curve to be stroked, and a preset expansion weight, obtain the curvature radius corresponding to the first curve;

[0093] Based on the curvature radius corresponding to the first curve and the expanded rectangle, obtain the first image.

[0094] In the embodiments of the present disclosure, obtaining the curvature radius corresponding to the first curve based on the curvature radius corresponding to the curve to be stroked, the stroke width of the curve to be stroked, and a preset expansion weight may include: obtaining a first radius value based on the stroke width of the curve to be stroked, a preset product number, and a preset expansion weight; obtaining the curvature radius corresponding to the first curve based on the sum of the first radius value and the curvature radius corresponding to the curve to be stroked. Here, both the product number and the expansion weight can be set according to actual needs, and the embodiments of the present disclosure do not limit this.

[0095] Exemplarily, when the product number is set to 0.5, the curvature radius corresponding to the first curve can be obtained through formula (3).

[0096] outRadius = Radius + strokeWidth * 0.5 * weight (3)

[0097] Wherein, outRadius represents the curvature radius corresponding to the first curve; Radius represents the curvature radius corresponding to the curve to be stroked; +weight represents the expansion weight.

[0098] In the embodiments of the present disclosure, obtaining the first image based on the curvature radius corresponding to the first curve and the expanded rectangle includes: drawing the first curve based on the curvature radius corresponding to the first curve and the expanded rectangle; performing image matching on the smallest rectangle covering the first curve to obtain the first image.

[0099] Here, drawing the first curve based on the curvature radius corresponding to the first curve and the expanded rectangle may include: using the point corresponding to the center point of the arc of the curve to be stroked in the expanded rectangle as the center point of the arc of the first curve, and drawing the first curve with the curvature radius corresponding to the first curve.

[0100] In the embodiments of the present disclosure, by adjusting the curvature radius corresponding to the curve to be stroked to obtain the first image with the first curve, the arc angle of the first curve can be made consistent with the curvature radius of the rounded corner at 45 degrees.

[0101] In some embodiments, processing the curve to be stroked to obtain a second image includes:

[0102] Shrink and translate the minimum rectangle covering the curve to be stroked to obtain a shrunk rectangle; wherein, the distance of each rectangle side of the minimum rectangle covering the curve to be stroked is translated inwardly by an equal distance.

[0103] Process the shrunk rectangle to obtain the second image.

[0104] In an embodiment of the present disclosure, shrinking and translating the minimum rectangle covering the curve to be stroked to obtain a shrunk rectangle includes: shrinking and translating the minimum rectangle covering the curve to be stroked based on a second translation distance to obtain a shrunk rectangle. Here, the second translation distance may be equal to or different from the first translation distance, and the embodiments of the present disclosure do not limit this.

[0105] Exemplarily, the shrunk rectangle can be obtained through formula (4).

[0106] in=rect.makeInset(intx,inty) (4)

[0107] Wherein, in represents the shrunk rectangle; strokeWidth represents the stroke width; rect represents the minimum rectangle covering the curve to be stroked; makeInset(intx, inty) represents that two adjacent rectangle sides of the minimum rectangle covering the curve to be stroked are respectively translated inwardly by the second translation distances x and y.

[0108] In an embodiment of the present disclosure, after obtaining the shrunk rectangle, the shrunk rectangle can be processed to obtain the second image. Here, in some embodiments, processing the shrunk rectangle to obtain the second image may include: performing image matching on the shrunk rectangle to obtain the second image. In other embodiments, processing the shrunk rectangle to obtain the second image includes:

[0109] Obtaining the curvature radius corresponding to the second curve based on the curvature radius corresponding to the curve to be stroked, the stroke width of the curve to be stroked, and a preset shrinking weight;

[0110] Obtaining the second image based on the curvature radius corresponding to the second curve and the shrunk rectangle.

[0111] In the embodiments of the present disclosure, obtaining the radius of curvature corresponding to the second curve based on the radius of curvature corresponding to the curve to be stroked, the stroke width of the curve to be stroked, and a preset reduction weight may include: obtaining a second radius value based on the stroke width of the curve to be stroked, a preset product number, and a preset reduction weight; obtaining the radius of curvature corresponding to the second curve based on the difference between the radius of curvature corresponding to the curve to be stroked and the second radius value. Here, both the product number and the reduction weight can be set according to actual requirements, and the embodiments of the present disclosure do not limit this.

[0112] Exemplarily, when the product number is set to 0.5, the radius of curvature corresponding to the first curve can be obtained through formula (5).

[0113] inRadius = Radius - strokeWidth * 0.5 * weight (5)

[0114] Wherein, inRadius represents the radius of curvature corresponding to the first curve; Radius represents the radius of curvature corresponding to the curve to be stroked; -weight represents the reduction weight.

[0115] In the embodiments of the present disclosure, obtaining the second image based on the radius of curvature corresponding to the second curve and the reduced rectangle includes: drawing the second curve based on the radius of curvature corresponding to the second curve and the reduced rectangle; performing image matching on the smallest rectangle covering the second curve to obtain the second image.

[0116] Here, drawing the second curve based on the radius of curvature corresponding to the second curve and the reduced rectangle may include: using the point corresponding to the center point of the arc of the curve to be stroked in the reduced rectangle as the center point of the arc of the second curve, and drawing the first curve with the radius of curvature corresponding to the second curve.

[0117] In the embodiments of the present disclosure, by adjusting the radius of curvature corresponding to the curve to be stroked to obtain the first image with the second curve, the arc angle of the second curve can be made consistent with the radius of curvature of the rounded corner at 45 degrees.

[0118] In some embodiments, obtaining the stroke result for the curve to be stroked based on the first image and the second image includes:

[0119] Sampling the first image and the second image respectively to obtain the sampled image of the first image and the sampled image of the second image;

[0120] Obtaining the stroke result for the curve to be stroked based on the sampled image of the first image and the sampled image of the second image.

[0121] In the embodiments of the present disclosure, after obtaining the first image and the second image, the first image and the second image may be subjected to coordinate transformation first to obtain the first image after coordinate transformation and the second image after coordinate transformation. Then, the first image after coordinate transformation and the second image after coordinate transformation are respectively sampled to obtain the sampled image of the first image and the sampled image of the second image. Here, through coordinate transformation, the first image and the second image can both be mapped to the same coordinate system, which facilitates the sampling process of the first image and the second image.

[0122] In some embodiments, respectively sampling the first image and the second image to obtain the sampled image of the first image and the sampled image of the second image includes:

[0123] Obtaining the sampled image of the first image based on the color information of the first image and the color information of the target image;

[0124] Obtaining the sampled image of the second image based on the color information of the second image and the color information of the target image.

[0125] In the embodiments of the present disclosure, obtaining the sampled image of the first image based on the color information of the first image and the color information of the target image includes: obtaining the sampled image of the first image based on the product between the color information of the first image and the color information of the target image.

[0126] Here, the sampled image of the first image can be obtained through formula (6).

[0127] colorOut = color1 * color2 (6)

[0128] Wherein, colorOut represents the sampled image of the first image; color1 is the color information of the first image; color2 is the color information of the target image.

[0129] In the embodiments of the present disclosure, the color information of the first image includes the red component value (R value), the green component value (G value), the blue component value (B value) of the first image, and the Alpha channel value (A value) of the first image. Among them, A is used as an opacity parameter. If A is 0, it corresponds to the first image being completely transparent; if A is between 0% and 100%, the first image can be displayed through the background.

[0130] It should be noted that obtaining the sampled image of the first image based on the product of the color information of the first image and the color information of the target image includes: obtaining the R value of the sampled image of the first image based on the product of the R value of the first image and the R value of the target image; obtaining the G value of the sampled image of the first image based on the product of the G value of the first image and the G value of the target image; obtaining the B value of the sampled image of the first image based on the product of the B value of the first image and the B value of the target image; obtaining the A value of the sampled image of the first image based on the product of the A value of the first image and the A value of the target image.

[0131] In an embodiment of the present disclosure, obtaining the sampled image of the second image based on the color information of the second image and the color information of the target image includes: obtaining the sampled image of the second image based on the product of the color information of the second image and the color information of the target image.

[0132] Here, the sampled image of the second image can be obtained through formula (7).

[0133] colorIn = color3 * color2 (7)

[0134] Wherein, colorIn represents the sampled image of the second image; color3 is the color information of the second image; color2 is the color information of the target image.

[0135] In an embodiment of the present disclosure, the color information of the second image includes the R value of the second image, the G value of the second image, the B value of the second image, and the A value of the second image.

[0136] It should be noted that obtaining the sampled image of the second image based on the product of the color information of the second image and the color information of the target image includes: obtaining the R value of the sampled image of the second image based on the product of the R value of the second image and the R value of the target image; obtaining the G value of the sampled image of the second image based on the product of the G value of the second image and the G value of the target image; obtaining the B value of the sampled image of the second image based on the product of the B value of the second image and the B value of the target image; obtaining the A value of the sampled image of the second image based on the product of the A value of the second image and the A value of the target image.

[0137] In the embodiments of the present disclosure, after obtaining the sampled image of the first image and the sampled image of the second image, a stroke result for the curve to be stroked can be obtained based on the sampled image of the first image and the sampled image of the second image. In some embodiments, obtaining a stroke result for the curve to be stroked based on the sampled image of the first image and the sampled image of the second image may include: obtaining difference color information based on the difference between a preset coefficient and the color information of the sampled image of the second image; and obtaining the stroke result based on the product between the difference color information and the color information of the sampled image of the first image.

[0138] Here, the stroke result can be obtained through formula (8).

[0139] color=(1.0 - color3)*color1 (8)

[0140] In the embodiments of the present disclosure, obtaining the stroke result based on the product between the difference color information and the color information of the sampled image of the first image may include: obtaining the R value of the stroke result based on the product between the R value of the difference color information and the R value of the sampled image of the first image; obtaining the G value of the stroke result based on the product between the G value of the difference color information and the G value of the sampled image of the first image; obtaining the B value of the stroke result based on the product between the B value of the difference color information and the B value of the sampled image of the first image; obtaining the A value of the stroke result based on the product between the A value of the difference color information and the A value of the sampled image of the first image.

[0141] To better understand the above one or more embodiments, examples of the embodiments of the present disclosure are as follows:

[0142] Figure 9 FIG. is a schematic diagram of a first curve and a second curve shown according to an exemplary embodiment. As Figure 9 shown, by adjusting the arc center point o1 of the first curve and the arc center point o2 of the second curve, the distance between the arc center point o1 of the first curve and the arc center point o3 of the curve to be stroked is made equal to the distance between the arc center point o2 of the second curve and the arc center point o3 of the curve to be stroked. In this way, the stroke width of the curve can be made consistent with the stroke width of the straight line, reducing the occurrence of sudden changes in the stroke.

[0143] Wherein, the arc center point of the first curve is the point where the perpendicular bisectors of any two points on the first curve intersect; the arc center point of the second curve is the point where the perpendicular bisectors of any two points on the second curve intersect; the arc center point of the curve to be stroked is the point where the perpendicular bisectors of any two points on the curve to be stroked intersect.

[0144] Figure 10A FIG. is a schematic diagram of an image processed by synthetic digital image according to an exemplary embodiment. Figure 10BSchematic diagram of processing an image using synthetic digital image according to an exemplary embodiment. Figure 10C Schematic diagram of processing an image using synthetic digital image according to an exemplary embodiment. As Figure 10A , Figure 10B , Figure 10C shown, by performing digital image combination on Image A and Image B, Image C can be obtained. Similarly, for the first image 12 and the second image 11 in Figure 7 , the stroked result in Figure 8 can be obtained through digital image combination of the second image 11 and the first image 12.

[0145] An embodiment of the present disclosure also provides a curve stroking device. Figure 11 Schematic diagram of the structure of a curve stroking device according to an exemplary embodiment. As Figure 11 shown, the curve stroking device 1000 includes:

[0146] An acquisition module 1001, configured to acquire a curve to be stroked in a target image;

[0147] A first processing module 1002, configured to process the curve to be stroked to obtain a first image, where the first image has a first curve;

[0148] A second processing module 1003, configured to process the curve to be stroked to obtain a second image, where the second image has a second curve different from the first curve; wherein, when the target image, the first image, and the second image are stacked, and the centers of the target image, the first image, and the second image coincide, the curve to be stroked is located between the first curve and the second curve, and the normal distances at different positions between the first curve and the second curve are equal;

[0149] An image obtaining module 1004, configured to obtain a stroked result for the curve to be stroked based on the first image and the second image.

[0150] In some embodiments, the first processing module 1002 is further configured to perform an expansion and translation process on the smallest rectangle covering the curve to be stroked to obtain an expanded rectangle; wherein the distances by which each side of the smallest rectangle covering the curve to be stroked is translated outward are equal; and process the expanded rectangle to obtain the first image.

[0151] In some embodiments, the first processing module 1002 is further configured to obtain the curvature radius of the first curve based on the curvature radius corresponding to the curve to be stroked, the stroke width of the curve to be stroked, and a preset expansion weight; and obtain the first image based on the curvature radius of the first curve and the expanded rectangle.

[0152] In some embodiments, the second processing module 1003 is further configured to perform a reduction and translation process on the smallest rectangle covering the curve to be stroked to obtain a reduced rectangle; wherein, the distance of inward translation of each rectangle side in the smallest rectangle covering the curve to be stroked is equal; and process the reduced rectangle to obtain the second image.

[0153] In some embodiments, the second processing module 1003 is further configured to obtain the curvature radius of the second curve based on the curvature radius corresponding to the curve to be stroked, the stroke width of the curve to be stroked, and a preset reduction weight; and obtain the second image based on the curvature radius of the second curve and the reduced rectangle.

[0154] In some embodiments, the image obtaining module 1004 is further configured to sample the first image and the second image respectively to obtain a sampled image of the first image and a sampled image of the second image; and obtain a stroke result for the curve to be stroked based on the sampled image of the first image and the sampled image of the second image.

[0155] In some embodiments, the image obtaining module 1004 is further configured to obtain a sampled image of the first image based on the color information of the first image and the color information of the target image; and obtain a sampled image of the second image based on the color information of the second image and the color information of the target image.

[0156] In some embodiments, the image obtaining module 1004 is further configured to obtain difference color information based on the difference between a preset coefficient and the color information of the sampled image of the second image; and obtain the stroke result based on the product between the difference color information and the color information of the sampled image of the first image.

[0157] The specific manners in which the respective modules in the device of the above embodiments perform operations have been described in detail in the embodiments related to the method, and will not be elaborated herein.

[0158] Figure 12It is a schematic structural diagram of an electronic device shown according to an exemplary embodiment. For example, the electronic device 800 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.

[0159] Referring to Figure 12 , the electronic device 800 may include one or more of the following components: a processing component 802, a memory 804, a power supply component 806, a multimedia component 808, an audio component 810, an input / output (I / O) interface 812, a sensor component 814, and a communication component 816.

[0160] The processing component 802 generally controls the overall operation of the electronic device 800, such as operations associated with display, telephone calls, data communication, camera operations, and recording operations. The processing component 802 may include one or more processors 820 to execute instructions to complete all or part of the steps of the above methods. In addition, the processing component 802 may include one or more modules to facilitate the interaction between the processing component 802 and other components. For example, the processing component 802 may include a multimedia module to facilitate the interaction between the multimedia component 808 and the processing component 802.

[0161] The memory 804 is configured to store various types of data to support the operation of the device 800. Examples of such data include instructions for any application or method operating on the electronic device 800, contact data, phone book data, messages, pictures, videos, etc. The memory 804 may be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, a magnetic disk, or an optical disk.

[0162] The power supply component 806 provides power to various components of the electronic device 800. The power supply component 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the electronic device 800.

[0163] The multimedia component 808 includes a screen that provides an output interface between the electronic device 800 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen can be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors can sense not only the boundaries of the touch or swipe actions, but also detect the duration and pressure associated with the touch or swipe operations. In some embodiments, the multimedia component 808 includes a front camera and / or a rear camera. When the device 800 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera can receive external multimedia data. Each of the front camera and the rear camera can be a fixed optical lens system or have a focal length and optical zoom capabilities.

[0164] The audio component 810 is configured to output and / or input audio signals. For example, the audio component 810 includes a microphone (MIC) that is configured to receive external audio signals when the electronic device 800 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals can be further stored in the memory 804 or transmitted via the communication component 816. In some embodiments, the audio component 810 further includes a speaker for outputting audio signals.

[0165] The I / O interface 812 provides an interface between the processing component 802 and a peripheral interface module, and the peripheral interface module can be a keyboard, a click wheel, buttons, etc. These buttons can include but are not limited to: a home button, a volume button, a power button, and a lock button.

[0166] The sensor component 814 includes one or more sensors for providing status assessments of various aspects of the electronic device 800. For example, the sensor component 814 can detect the on / off state of the device 800, the relative positioning of components, such as the display and keypad of the electronic device 800. The sensor component 814 can also detect a change in the position of the electronic device 800 or a component of the electronic device 800, the presence or absence of user contact with the electronic device 800, the orientation or acceleration / deceleration of the electronic device 800, and the temperature change of the electronic device 800. The sensor component 814 can include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor component 814 can also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor component 814 can further include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.

[0167] The communication component 816 is configured to facilitate communication, either wired or wirelessly, between the electronic device 800 and other devices. The electronic device 800 may access a communication standard-based wireless network, such as WiFi, 3G, or 5G, or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 further includes a Near Field Communication (NFC) module to facilitate short-range communication. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, Infrared Data Association (IrDA) technology, Ultra Wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.

[0168] In an exemplary embodiment, the electronic device 800 may be implemented by one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components for performing the above method.

[0169] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions, such as the memory 804 including instructions, is also provided. The above instructions may be executed by the processor 820 of the electronic device 800 to complete the above method. For example, the non-transitory computer-readable storage medium may be a ROM, Random Access Memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device, etc.

[0170] A non-transitory computer-readable storage medium, when the instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to execute a curve tracing method, the method including: obtaining a curve to be traced in a target image; processing the curve to be traced to obtain a first image having a first curve; processing the curve to be traced to obtain a second image having a second curve different from the first curve; wherein, when the target image, the first image, and the second image are stacked and the centers of the target image, the first image, and the second image coincide, the curve to be traced is located between the first curve and the second curve, and the normal distances at different positions between the first curve and the second curve are equal; obtaining a tracing result for the curve to be traced based on the first image and the second image.

[0171] Other embodiments of the present disclosure will be readily apparent to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include known common general knowledge or conventional technical means in the technical field not disclosed in the present disclosure. The specification and examples are only to be considered as exemplary, and the true scope and spirit of the present disclosure are pointed out by the following claims.

[0172] It should be understood that the present disclosure is not limited to the exact structures described above and shown in the drawings, and various modifications and changes can be made without departing from its scope. The scope of the present disclosure is only limited by the appended claims.

Claims

1. A curve tracing method, characterized in that, Including: Obtain the curve to be stroked in the target image; Process the curve to be stroked to obtain a first image, where the first image has a first curve; Process the curve to be stroked to obtain a second image, where the second image has a second curve different from the first curve; wherein, when the target image, the first image, and the second image are stacked, and the centers of the target image, the first image, and the second image coincide, the curve to be stroked is located between the first curve and the second curve, and the normal distances at different positions between the first curve and the second curve are equal; Based on the first image and the second image, obtain a stroke result for the curve to be stroked.

2. The method according to claim 1, characterized in that, The process of processing the curve to be stroked to obtain a first image includes: Perform an enlarged translation process on the smallest rectangle covering the curve to be stroked to obtain an enlarged rectangle; wherein, the distances by which each side of the smallest rectangle covering the curve to be stroked is translated outward are equal; Process the enlarged rectangle to obtain the first image.

3. The method according to claim 2, characterized in that, The process of processing the enlarged rectangle to obtain the first image includes: Based on the curvature radius corresponding to the curve to be stroked, the stroke width of the curve to be stroked, and a preset enlargement weight, obtain the curvature radius corresponding to the first curve; Based on the curvature radius corresponding to the first curve and the enlarged rectangle, obtain the first image.

4. The method according to any one of claims 1 to 3, characterized in that, The process of processing the curve to be stroked to obtain a second image includes: Perform a reduced translation process on the smallest rectangle covering the curve to be stroked to obtain a reduced rectangle; wherein, the distances by which each side of the smallest rectangle covering the curve to be stroked is translated inward are equal; Process the reduced rectangle to obtain the second image.

5. The method according to claim 4, characterized in that, The process of processing the reduced rectangle to obtain the second image includes: Based on the curvature radius corresponding to the curve to be stroked, the stroke width of the curve to be stroked, and a preset reduction weight, obtain the curvature radius corresponding to the second curve; Based on the curvature radius corresponding to the second curve and the reduced rectangle, obtain the second image.

6. The method according to any one of claims 1 to 3, characterized in that, The obtaining of the stroke result for the curve to be stroked based on the first image and the second image includes: Sample the first image and the second image respectively to obtain a sampled image of the first image and a sampled image of the second image; Based on the sampled image of the first image and the sampled image of the second image, obtain a stroke result for the curve to be stroked.

7. The method according to claim 6, characterized in that, The sampling of the first image and the second image respectively to obtain a sampled image of the first image and a sampled image of the second image includes: Based on the color information of the first image and the color information of the target image, obtain a sampled image of the first image; Based on the color information of the second image and the color information of the target image, obtain a sampled image of the second image.

8. The method according to claim 6, characterized in that, Obtaining a stroke result for the curve to be stroked based on the sampled image of the first image and the sampled image of the second image, including: Obtaining difference color information based on the difference between a preset coefficient and the color information of the sampled image of the second image; Obtaining the stroke result based on the product between the difference color information and the color information of the sampled image of the first image.

9. A curve tracing device, characterized in that, Including: An acquisition module configured to acquire a curve to be stroked in a target image; A first processing module configured to process the curve to be stroked to obtain a first image having a first curve; A second processing module configured to process the curve to be stroked to obtain a second image having a second curve different from the first curve; wherein, when the target image, the first image and the second image are stacked and the centers of the target image, the first image and the second image coincide, the curve to be stroked is located between the first curve and the second curve, and the normal distances at different positions between the first curve and the second curve are equal; An image obtaining module configured to obtain a stroke result for the curve to be stroked based on the first image and the second image.

10. An electronic device, characterized in that, Including: A processor; A memory for storing processor-executable instructions; Wherein, the processor is configured to execute the curve stroking method according to any one of claims 1 to 8.

11. A non-transitory computer-readable storage medium, when the instructions in the storage medium are executed by a processor of an electronic device, enabling the electronic device to execute the curve tracing method according to any one of claims 1 to 8.