Methods and apparatus for handling gradients at curved edges
By acquiring and processing the intersection points and diagonal ratios of image pixels and calculating the gain value, the problems of poor gradient effects and jagged edges in existing technologies are solved, and high-quality curve edge gradient processing is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-04
- Publication Date
- 2026-04-03
AI Technical Summary
Existing technologies struggle to achieve pixel-level processing of controllable gradient ranges in image processing, and suffer from noticeable jagged edges and poor gradient effects, making them particularly unsuitable for gradient processing of various curved or graphic edges.
By obtaining the intersection points of the upper and lower boundaries of the pixels with the area to be gradientd, rounding them to the nearest pixel boundary line, determining the longer diagonal, calculating the gain value based on the diagonal division ratio, and determining the output pixel value based on the input pixel value and the gain value, the gradient processing is achieved.
It achieves controllable gradient effects on the edges of various curves, reduces edge jaggedness, improves gradient quality, and is suitable for gradient processing of various curves and graphic edges.
Smart Images

Figure CN117173048B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of image processing technology, and in particular to a method and apparatus for processing curve edge gradients. Background Technology
[0002] In image processing, it is often necessary to apply gradient effects from the curved edges of a graphic to the background. Current techniques are based on distance, which typically fails to achieve pixel-level control over the gradient range and suffers from noticeable jagged edges and poor gradient effects. Furthermore, existing methods have limitations, being applicable only to specific curves or graphics. Therefore, there is an urgent need for a more comprehensive and high-performance method to achieve gradient effects on curved edges. Summary of the Invention
[0003] In view of the above problems, this disclosure provides a method and related methods and apparatus for processing curve edge gradients, which aims to achieve better gradient effects for various curve edges through simple calculations.
[0004] According to a first aspect of this disclosure, a method for processing curve edge gradients is provided, comprising:
[0005] Obtain the intersection points of the upper and lower boundaries of a row of pixels with the two edge curves of the area to be gradientd;
[0006] The x-coordinate of the intersection point is rounded to the nearest pixel boundary to obtain the updated intersection point.
[0007] The longer of the two diagonals formed by the updated intersection is determined, and the gain value of the corresponding pixel is determined according to the division ratio of the area of each pixel in the row by the determined diagonal.
[0008] The output pixel value after gradient processing is determined based on the input pixel value and the gain value.
[0009] Optionally, the intersection points of the upper and lower boundaries of a row of pixels with the two edge curves of the region to be gradient are obtained, including:
[0010] Obtain the equations for the upper and lower boundaries of the pixels in this row, resulting in two straight line equations;
[0011] Obtain the equations of the two edge curves of the region to be gradiented, resulting in two curve equations; based on the two line equations and the two curve equations, calculate the coordinates of the intersection points of the upper and lower boundaries of the pixel row with the two edge curves of the region to be gradiented.
[0012] Optionally, the intersection points of the upper and lower boundaries of a row of pixels with the two edge curves of the region to be gradient are obtained, including:
[0013] Obtain the equations for the upper and lower boundaries of the pixels in this row, resulting in two straight line equations;
[0014] Obtain the equation of one edge curve of the region to be gradiented, and calculate the equation of the other edge curve of the region to be gradiented based on the obtained equation and a preset gradient width.
[0015] Based on the equations of the two lines and the equations of the two edge curves of the region to be gradiented, calculate the coordinates of the intersection points of the upper and lower boundaries of the pixel in the row with the two edge curves of the region to be gradiented.
[0016] Optionally, the equation for another edge curve of the region to be gradient is calculated based on the obtained equation according to the preset gradient width, including: calculating the equation of the curve obtained by translating the edge curve corresponding to the obtained equation by the preset gradient width.
[0017] Optionally, the equation for another edge curve of the region to be gradient is calculated based on the obtained equation according to the preset gradient width, including: calculating the equation of the curve obtained by scaling the edge curve corresponding to the obtained equation along the radius of curvature to the preset gradient width.
[0018] Optionally, the gain value of the corresponding pixel is determined according to the division ratio of the area of each pixel in the row by the determined diagonal, including: determining the ratio of the area of a pixel in the row on one side of the graphic of the determined diagonal to the pixel area as the gain value of the pixel.
[0019] Determining the output pixel value after gradient processing based on the input pixel value of a pixel and the gain value includes: adding the product of the input pixel value of the pixel and the gain value to the product of the input pixel value of the background and the difference between 1 and the gain value, to obtain the output pixel value of the pixel.
[0020] Optionally, the gain value of the corresponding pixel is determined according to the division ratio of the area of each pixel in the row by the determined diagonal, including: determining the ratio of the area of a pixel in the row on the background side of the determined diagonal to the pixel area as the gain value of the pixel.
[0021] Determining the output pixel value after gradient processing based on the input pixel value of a pixel and the gain value includes: adding the product of the input pixel value of the pixel and the difference between 1 and the gain value to the product of the input pixel value of the background and the gain value to obtain the output pixel value of the pixel.
[0022] According to a second aspect of this disclosure, a method for determining the gain value in curve edge gradient processing is provided, comprising:
[0023] Obtain the intersection points of the upper and lower boundaries of a row of pixels with the two edge curves of the area to be gradientd;
[0024] The x-coordinate of the intersection point is rounded to the nearest pixel boundary to obtain the updated intersection point.
[0025] The longer of the two diagonals formed by the updated intersection is determined, and the gain value of the corresponding pixel in the gradient processing is determined according to the division ratio of the area of each pixel in the row by the determined diagonal.
[0026] Optionally, the intersection points of the upper and lower boundaries of a row of pixels with the two edge curves of the region to be gradient are obtained, including:
[0027] Obtain the equations for the upper and lower boundaries of the pixels in this row, resulting in two straight line equations;
[0028] Obtain the equations of the two edge curves of the region to be gradually changed, thus obtaining two curve equations;
[0029] Based on the two straight line equations and the two curve equations, calculate the coordinates of the intersection points of the upper and lower boundaries of the row of pixels with the two edge curves of the region to be gradient.
[0030] Optionally, the intersection points of the upper and lower boundaries of a row of pixels with the two edge curves of the region to be gradient are obtained, including:
[0031] Obtain the equations for the upper and lower boundaries of the pixels in this row, resulting in two straight line equations;
[0032] Obtain the equation of one edge curve of the region to be gradiented, and calculate the equation of the other edge curve of the region to be gradiented based on the obtained equation and a preset gradient width.
[0033] Based on the equations of the two lines and the equations of the two edge curves of the region to be gradiented, calculate the coordinates of the intersection points of the upper and lower boundaries of the pixel in the row with the two edge curves of the region to be gradiented.
[0034] Optionally, the equation for another edge curve of the region to be gradient is calculated based on the obtained equation according to the preset gradient width, including: calculating the equation of the curve obtained by translating the edge curve corresponding to the obtained equation by the preset gradient width.
[0035] Optionally, the equation for another edge curve of the region to be gradient is calculated based on the obtained equation according to the preset gradient width, including: calculating the equation of the curve obtained by scaling the edge curve corresponding to the obtained equation along the radius of curvature to the preset gradient width.
[0036] According to a third aspect of this disclosure, an electronic device is provided, comprising: a processor, a memory, and a program stored in the memory and executable on the processor, wherein the program, when executed by the processor, implements the steps of any of the processing methods described in the first aspect or the steps of any of the determining methods described in the second aspect.
[0037] According to a fourth aspect of this disclosure, a computer-readable storage medium is provided, on which a computer program or instructions are stored, wherein when executed by a processor, the computer program or instructions implement the steps of any of the processing methods described in the first aspect or the steps of any of the determining methods described in the second aspect.
[0038] This disclosure brings the following beneficial effects:
[0039] In determining the gain value in the gradient processing of curved edges, this disclosure first obtains the intersection points of the upper and lower boundaries of a row of pixels with the two edge curves of the area to be gradiented. Then, the x-coordinates of the intersection points are rounded to the nearest pixel boundary to obtain the updated intersection points. Next, the longer of the two diagonals formed by the updated intersection points is determined, and the gain value of the corresponding pixel is determined according to the division ratio of the area of each pixel in the row by the determined diagonal. The calculation involved in this whole process is relatively simple and applicable to the determination of the gain value of the area to be gradiented with various curved edges. It also has significant improvements in anti-aliasing and gradient effect.
[0040] Other features and advantages of this disclosure will be set forth in the following description and will be apparent in part from the description or may be learned by practicing the disclosure. The objects and other advantages of this disclosure are realized and obtained through the structures particularly pointed out in the description and the drawings.
[0041] To make the above-mentioned objects, features and advantages of this disclosure more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0042] The above and other objects, features and advantages of this disclosure will become clearer from the following description of embodiments with reference to the accompanying drawings, in which:
[0043] Figures 1(a) and 1(b) show two exemplary cases of noticeably jagged edges obtained by existing processing methods for curve edge gradients;
[0044] Figures 2(a) and 2(b) show two exemplary cases of poor gradient effects obtained by existing processing methods for curve edge gradients;
[0045] Figure 3 The diagram shown is a flowchart of a method for processing curve edge gradients according to an embodiment of the present disclosure;
[0046] Figures 4(a), 4(b), 4(c) and 4(d) show the longer diagonal lines corresponding to the edge curves at the four vertices of a figure according to an embodiment of the present disclosure;
[0047] Figures 5(a) and 5(b) show two graphics obtained by processing the curve edge gradient processing method provided in an embodiment of this disclosure;
[0048] Figure 6 The image shown is an illustration of the effect of applying the curve edge gradient processing method provided in this embodiment of the present disclosure to the straight edge gradient processing;
[0049] Figure 7 The diagram shown is a flowchart of a method for determining the gain value in a curve edge gradient processing according to another embodiment of the present disclosure;
[0050] Figure 8 The diagram shown is an exemplary structural schematic of a chip according to yet another embodiment of the present disclosure. Detailed Implementation
[0051] Various embodiments of the present disclosure will now be described in more detail with reference to the accompanying drawings. In the various drawings, the same elements are indicated by the same or similar reference numerals. For clarity, the various portions in the drawings are not drawn to scale.
[0052] Existing methods for processing curved edge gradients are based on distance, which typically fails to achieve pixel-level processing for controllable gradient ranges. Furthermore, they suffer from problems such as noticeable jagged edges and poor gradient effects. Figures 1(a) and 1(b) illustrate two examples of cases with noticeable jagged edges, while Figures 2(a) and 2(b) illustrate two examples of cases with poor gradient effects. In addition, existing methods have limitations in application and are not suitable for gradient processing of various curved edges or graphic edges.
[0053] Therefore, this disclosure provides a method for processing curve edge gradients with good overall performance. Figure 3 The diagram shows a flowchart of a method for processing curve edge gradients according to an embodiment of this disclosure. (Refer to...) Figure 3 The processing method includes:
[0054] Step S110: Obtain the intersection points of the upper and lower boundaries of a row of pixels with the two edge curves of the area to be gradient.
[0055] It should be noted that the curved edges of the graphic need to undergo a gradient process to the background. Specifically, the inner part of the curved edge of the graphic is the area to be gradientd, defined by two edge curves, one of which is the graphic's own edge curve. The aforementioned row of pixels represents the current row of pixels to be processed in the graphic. After all rows of pixels in the graphic have been processed, the entire graphic's curved edge gradient process is complete.
[0056] Specifically, the upper and lower boundaries of a row of pixels each have two intersection points with the two edge curves of the area to be gradient, so this step obtains four intersection points.
[0057] Step S120: Round the x-coordinate of the intersection point to the nearest pixel boundary line to obtain the updated intersection point.
[0058] Specifically, the updated intersection point is obtained by moving the intersection point horizontally. If the intersection point is closer to the left-hand neighboring pixel boundary line in the horizontal direction, the updated intersection point is obtained by moving the intersection point to the left in the horizontal direction; if the intersection point is closer to the right-hand neighboring pixel boundary line in the horizontal direction, the updated intersection point is obtained by moving the intersection point to the right in the horizontal direction.
[0059] It's important to note that since the intersection point is obtained based on the upper and lower boundaries of a row of pixels, its ordinate lies on the vertical boundary line between pixels, i.e., on the horizontal boundary line. This step rounds the intersection point's abscissa to the nearest pixel boundary line, thus shifting the abscissa to the horizontal boundary line between pixels, i.e., to the vertical boundary line. Therefore, the updated intersection point is located at a vertex of a pixel.
[0060] Step S130: Determine the longer of the two diagonals formed by the updated intersection points, and determine the gain value of the corresponding pixel based on the division ratio of the area of each pixel in the row by the determined diagonal.
[0061] Specifically, since there are four intersection points, there are also four updated intersection points. Figures 4(a), 4(b), 4(c), and 4(d) show the longer diagonals corresponding to the edge curves at the four vertices of the figure. Points A, B, C, and D indicate the intersection points, and points A', B', C', and D' indicate the updated intersection points. In Figure 4(a), the case of the upper left corner of the figure is shown, and diagonal B'C' is the longer diagonal. In Figure 4(b), the case of the upper right corner of the figure is shown, and diagonal A'D' is the longer diagonal. In Figure 4(c), the case of the lower left corner of the figure is shown, and diagonal A'D' is the longer diagonal. In Figure 4(d), the case of the lower right corner of the figure is shown, and diagonal B'C' is the longer diagonal.
[0062] It should be noted that in some examples, the two edge curves of the area to be gradient in the graphic will gradually become straight lines at the end. This may cause one of the upper and lower boundaries of individual rows of pixels in the graphic to no longer intersect with one of the edge curves or even with neither edge curve. In this case, the intersection of the straight line obtained by connecting the dividing points where the two edge curves gradually become straight lines with the upper and lower boundaries of the row of pixels can be used as the required partial intersection points to perform the relevant processing.
[0063] For example, as shown in Figure 4(c), the right ends of the two edge curves gradually transition to straight lines, and the upper and lower boundary lines of the second-to-last row of pixels no longer intersect with one of the edge curves. The intersection point (marked with a hollow circle) of the straight line obtained by connecting the dividing points (indicated by solid squares) where the right ends of the two edge curves gradually transition to straight lines with the upper and lower boundary lines of that row of pixels is used as the required intersection point for the relevant processing. In this example, the area defined by the straight line connecting the two edge curves to the right of the dividing point can achieve a gradient effect using existing techniques for processing straight-line edge gradients.
[0064] Step S140: Determine the output pixel value after gradient processing based on the input pixel value and gain value of the pixel.
[0065] It should be noted that the pixels along the diagonal line determined in step S130 are the pixels whose pixel values need to be changed to achieve the gradient effect, and each pixel along the diagonal line determined in step S130 has a assigned gain value. In this step, for the pixels whose pixel values need to be changed, the input pixel value is changed by the gain value to obtain the output pixel value.
[0066] The method for processing curved edge gradients provided in this disclosure requires that each pixel, which achieves the gradient effect by changing its pixel value, has a gain value obtained by dividing its own area based on a determined diagonal. Therefore, it can achieve pixel-level processing with a controllable gradient range. Furthermore, this method determines the gain value based on the area divided by a diagonal formed by the updated intersection point. Since the updated intersection point is on a vertex of the pixel, the divided area can be determined using the triangle area calculation formula, without involving complex integration calculations. This simplifies the entire calculation process, and the gradient processing based on the updated intersection point obtained by rounding has minimal impact on the gradient effect. This method is applicable to determining the gain value of regions with various curved edges to be gradientd, thereby enabling gradient processing for regions with various curved edges.
[0067] In an optional embodiment, step S110, obtaining the intersection points of the upper and lower boundaries of a row of pixels with the two edge curves of the region to be gradient, includes: obtaining the equations of the upper and lower boundaries of the row of pixels to obtain two straight line equations; obtaining the equations of the two edge curves of the region to be gradient to obtain two curve equations; and calculating the coordinates of the intersection points of the upper and lower boundaries of the row of pixels with the two edge curves of the region to be gradient based on the two straight line equations and the two curve equations. The two curve equations are predetermined; the region to be gradient may be predefined by two edge curves with their respective curve equations, thus allowing for direct acquisition of these two curve equations, which helps to accelerate the gradient processing.
[0068] In another optional embodiment, step S110, obtaining the intersection points of the upper and lower boundaries of a row of pixels with the two edge curves of the area to be gradient, includes: obtaining the equations of the upper and lower boundaries of the row of pixels to obtain two straight line equations; obtaining the equation of one edge curve of the area to be gradient, which is mostly the boundary line between the graphic and the background defined in advance by an equation, so the equation defining the edge curve can be obtained directly; then, based on the obtained equation, calculating the equation of the other edge curve of the area to be gradient according to the preset gradient width; and then, based on the two straight line equations and the equations of the two edge curves of the area to be gradient, calculating the coordinates of the intersection points of the upper and lower boundaries of the row of pixels with the two edge curves of the area to be gradient.
[0069] Furthermore, the equation for calculating the other edge curve of the region to be gradient based on the obtained equation and the preset gradient width can be an equation for the curve obtained by translating the edge curve corresponding to the obtained equation by the preset gradient width. The curve obtained by translating the edge curve corresponding to the obtained equation by the preset gradient width is the other edge curve of the region to be gradient. The translation can be along a 45° angle. Referring to Figure 4(a), for the region to be gradient in the upper left corner, it can be translated to the lower right corner along a 45° angle from the upper left corner to the lower right corner; referring to Figure 4(b), for the region to be gradient in the upper right corner, it can be translated to the lower left corner along a 45° angle from the upper right corner to the lower left corner; referring to Figure 4(c), for the region to be gradient in the lower left corner, it can be translated to the upper right corner along a 45° angle from the lower left corner to the upper right corner; referring to Figure 4(d), for the region to be gradient in the lower right corner, it can be translated to the upper left corner along a 45° angle from the lower right corner to the upper left corner.
[0070] The equation described above, which calculates the other edge curve of the region to be gradient based on the obtained equation and a preset gradient width, can also be an equation that calculates the curve obtained by scaling the edge curve corresponding to the obtained equation along the radius of curvature to the preset gradient width. The curve obtained by scaling the edge curve corresponding to the obtained equation along the radius of curvature to the preset gradient width is the other edge curve of the region to be gradient. Specifically, if the obtained equation is the boundary line between the graphic and the background, the other edge curve of the region to be gradient is obtained by reducing the preset gradient width along the radius of curvature; if the obtained equation is not the boundary line between the graphic and the background, the other edge curve of the region to be gradient is obtained by increasing the preset gradient width along the radius of curvature.
[0071] Both of the above equations for calculating the other edge curve can be obtained by making simple modifications to the obtained equations, thus not leading to a significant increase in the amount of computation.
[0072] In some examples, step S130 determines the gain value of the corresponding pixel based on the division ratio of the area of each pixel in the row by the determined diagonal, including: determining the ratio of the area of the pixel on one side of the graphic of the determined diagonal to the pixel area as the gain value of the pixel; step S140 determines the output pixel value after gradient processing based on the input pixel value and the gain value of the pixel, including: adding the product of the input pixel value and the gain value of the pixel to the product of the input pixel value of the background and the difference between 1 and the gain value, to obtain the output pixel value of the pixel, as shown in formula (1), where Output represents the output pixel value of the pixel, input1 represents the input pixel value of the same pixel, gain represents the gain value of the same pixel, and input2 represents the input pixel value of the background.
[0073] Output=input1×gain+input2×(1-gain) (1)
[0074] Taking Figure 4(b) as an example, the calculation of the gain value in this example is explained. The area of the diagonal fill portion of each pixel is the area of one side of the defined diagonal pattern. Let the pixel size be 1×1. The areas of the three pixels traversed by the defined diagonal in Figure 4(b) from right to left on one side of the defined diagonal pattern are: 1 / 6, 1 / 2, and 5 / 6. Since the pixel area is 1, the gain values of the three pixels involved from right to left are also: 1 / 6, 1 / 2, and 5 / 6.
[0075] It should be noted that formula (1) is a universal formula. If the background is black as shown in Figure 1(a) and Figure 2(a), then the input pixel value of the background is input2 = 0, and formula (1) is transformed into formula (2) as shown below.
[0076] Output = input1 × gain (2)
[0077] In addition, if the graphic is white as shown in Figure 1(b) and Figure 2(b), then the input pixel value input1 = 255, and then formula (1) is transformed into formula (3) as shown below.
[0078] Output=gain×255+input2×(1-gain) (3)
[0079] In other examples, step S130, determining the gain value of the corresponding pixel based on the division ratio of the area of each pixel in the row by the determined diagonal, includes: determining the ratio of the area of a pixel in the row on the background side of the determined diagonal to the pixel area as the gain value of the pixel; step S140, determining the output pixel value after gradient processing based on the input pixel value and the gain value of the pixel, includes: adding the product of the difference between the input pixel value of the pixel and 1 minus the gain value to the product of the input pixel value of the background and the gain value to obtain the output pixel value of the pixel, as shown in formula (4), where Output represents the output pixel value of the pixel, input1 represents the input pixel value of the same pixel, gain represents the gain value of the same pixel, and input2 represents the input pixel value of the background.
[0080] Output=input1×(1-gain)+input2×gain (4)
[0081] Using Figure 4(b) as an example, the calculation of the gain value in this example is explained. The area of the dot-filled portion of each pixel is the area of the background side of the determined diagonal. Let the pixel size be 1×1. The areas of the three pixels traversed by the determined diagonal in Figure 4(b) from right to left on the background side of the determined diagonal are: 5 / 6, 1 / 2, and 1 / 6 respectively. Since the pixel area is 1, the gain values of the three pixels involved from right to left are also: 5 / 6, 1 / 2, and 1 / 6 respectively.
[0082] Similarly, formula (4) is a universal formula. If the background is black as shown in Figure 1(a) and Figure 2(a), then the input pixel value of the background is input2 = 0, and formula (4) is transformed into formula (5) as shown below.
[0083] Output = input1 × (1 - gain) (5)
[0084] In addition, if the graphic is white as shown in Figure 1(b) and Figure 2(b), then the input pixel value input1 = 255, and then formula (4) is transformed into formula (6) as shown below.
[0085] Output=(1-gain)×255+input2×gain (6)
[0086] It should be noted that the above formulas (1) and (4) are applicable not only to grayscale graphics but also to color graphics. When used for gradient processing from color graphics to background, the output pixel values of each pixel in the red, green and blue channels should be calculated separately. When calculating the output pixel value of a certain channel, the parameters input1 and input2 in the formula also use the values of the same channel.
[0087] Figures 5(a) and 5(b) show two graphics obtained by the curve edge gradient processing method provided in the embodiments of this disclosure. Compared with the prior art, they have significant improvements in anti-aliasing and gradient effect.
[0088] It should be noted that the method for processing curve edge gradients provided in this disclosure can also be applied to the processing of straight edge gradients. In this case, the two diagonals formed by the updated intersection points have the same length. Therefore, in step S130, either one can be selected to determine the pixel gain, thereby performing gradient processing based on the determined pixel gain. Figure 6 The figure shown is an effect diagram of the processing of straight edge gradient using the curve edge gradient processing method provided in the embodiment of this disclosure. It can be seen from the figure that the gradient effect is quite ideal.
[0089] Another embodiment of this disclosure also provides a method for determining the gain value in curve edge gradient processing. Figure 7 The flowchart shown is for this determination method. Figure 7 The determination method includes:
[0090] Step S210: Obtain the intersection points of the upper and lower boundaries of a row of pixels with the two edge curves of the area to be gradient.
[0091] Step S220: Round the x-coordinate of the intersection point to the nearest pixel boundary line to obtain the updated intersection point.
[0092] Step S230: Determine the longer of the two diagonals formed by the updated intersection points, and determine the gain value of the corresponding pixel in the gradient processing based on the division ratio of the area of each pixel in the row by the determined diagonal.
[0093] In an optional embodiment, step S210, obtaining the intersection points of the upper and lower boundaries of a row of pixels with the two edge curves of the region to be gradient, includes: obtaining the equations of the upper and lower boundaries of the row of pixels to obtain two straight line equations; obtaining the equations of the two edge curves of the region to be gradient to obtain two curve equations; and calculating the coordinates of the intersection points of the upper and lower boundaries of the row of pixels with the two edge curves of the region to be gradient based on the two straight line equations and the two curve equations.
[0094] In another optional embodiment, step S210, obtaining the intersection points of the upper and lower boundaries of a row of pixels with the two edge curves of the region to be gradient, includes: obtaining the equations of the upper and lower boundaries of the row of pixels to obtain two straight line equations; obtaining the equation of one edge curve of the region to be gradient, and calculating the equation of the other edge curve of the region to be gradient based on the obtained equation and a preset gradient width; and calculating the coordinates of the intersection points of the upper and lower boundaries of the row of pixels with the two edge curves of the region to be gradient based on the two straight line equations and the equations of the two edge curves of the region to be gradient.
[0095] Furthermore, the equation for calculating another edge curve of the region to be gradient based on the obtained equation and the preset gradient width can be either the equation of the edge curve corresponding to the obtained equation translated by the preset gradient width, or the equation of the edge curve corresponding to the obtained equation scaled along the radius of curvature to obtain the preset gradient width.
[0096] The method for determining the gain value in curve edge gradient processing provided in this disclosure allows pixels to have a gain value obtained by dividing their own area based on a determined diagonal, thus enabling pixel-level processing with a controllable gradient range. Furthermore, this method determines the gain value by dividing the area of a diagonal formed by the updated intersection point. Since the updated intersection point is at a vertex of the pixel, the divided area can be determined using the triangle area calculation formula, eliminating the need for complex integration calculations. This simplifies the entire calculation process, and the gain value determined based on the updated intersection point obtained through rounding has minimal impact on the curve edge gradient effect. This method is applicable to determining the gain value of regions to be gradientd with various curve edges and helps solve problems such as jagged edges and poor gradient effects.
[0097] Since the steps used in the method for determining the gain value in the curve edge gradient processing provided in this disclosure are all present in the curve edge gradient processing method provided in the above embodiments, the execution details of each step in this disclosure can be referred to the corresponding parts in the embodiments of the curve edge gradient processing method, and will not be repeated here.
[0098] Corresponding to the above method embodiments, another embodiment of this disclosure provides an electronic device. Figure 8 The image shows an exemplary electronic device. (As shown) Figure 8 As shown, the electronic device 1300 includes a memory 1310 and a processor 1320, as well as a program stored in the memory 1310 and executable on the processor 1320. When the program is executed by the processor 1320, it can implement the steps of the embodiments of the above processing method or the steps of the embodiments of the above determination method, and can achieve the same technical effect.
[0099] Specifically, if the above program is executed by processor 1320 and implements the steps of each embodiment of the above processing method, then electronic device 1300 can be a display driver integrated circuit (DDIC), that is, electronic device 1300 internally calculates the gain value and performs gradient processing in the graphics display process using the calculated gain value. If the above program is executed by processor 1320 and implements the steps of each embodiment of the above determination method, then electronic device 1300 can be an application processor (AP). In this case, the gain value determined by the application processor can be first stored in static random-access memory (SRAM), and then the display driver chip reads the gain value from the static random-access memory during operation to perform gradient processing in the graphics display process.
[0100] Of course, the electronic device 1300 may also include auxiliary devices such as a network interface 1330 and an input / output interface 1340 to achieve the acquisition of various required data or the output of results in the above method embodiments.
[0101] Those skilled in the art will understand that all or part of the steps in the above method embodiments can be implemented by instructions, or by instructions controlling related hardware. These instructions can be stored in a computer-readable storage medium and loaded and executed by a processor. Therefore, in another embodiment of this disclosure, a computer-readable storage medium is provided, on which a computer program is stored. When executed by a processor, the computer program can implement the steps of the embodiments of the above processing methods or the steps of the embodiments of the above determining methods. The computer-readable storage medium includes various media capable of storing program code, such as a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0102] Since the program stored in the readable storage medium can execute the steps of the various embodiments of the processing methods or the various embodiments of the determination methods provided in the embodiments of this disclosure, the beneficial effects that any processing method or any determination method provided in the embodiments of this disclosure can achieve can be realized, as detailed in the preceding embodiments, and will not be repeated here. The specific implementation of each of the above operations can be found in the preceding embodiments, and will not be repeated here.
[0103] It should be noted that in describing the various embodiments in this specification, the focus is on the differences from other embodiments, while the same or similar parts between the various embodiments can be understood by referring to each other. Regarding the electronic device embodiment, since it is basically similar to the method embodiment, the relevant parts can be referred to the description of the method embodiment. Because this electronic device embodiment has the beneficial effects that can be achieved by the above-described method embodiments, as detailed in the preceding embodiments, it will not be repeated here.
[0104] Furthermore, it should be noted that in the apparatus and method of this disclosure, it is obvious that the components or steps can be decomposed and / or recombined. These decompositions and / or recombinations should be considered equivalent solutions of this disclosure. Moreover, the steps performing the above series of processes can naturally be executed in the order described, but are not necessarily required to be executed in chronological order; some steps can be executed in parallel or independently of each other. Those skilled in the art will understand that all or any step or component of the method and apparatus of this disclosure can be implemented in any computing device (including processors, storage media, etc.) or network of computing devices, in hardware, firmware, software, or a combination thereof, which can be achieved by those skilled in the art using their basic programming skills after reading the description of this disclosure.
[0105] Finally, it should be noted that the terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance. Furthermore, the embodiments described above are merely specific implementations of this disclosure, used to illustrate the technical solutions of this disclosure, and not to limit it. The scope of protection of this disclosure is not limited thereto. Although this disclosure has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features, within the scope of the technology disclosed in this disclosure; and these modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this disclosure, and should all be covered within the scope of protection of this disclosure. Therefore, the scope of protection of this disclosure should be determined by the scope of the claims.
Claims
1. A method for processing curve edge gradients, comprising: Obtain the intersection points of the upper and lower boundaries of a row of pixels with the two edge curves of the area to be gradientd; The x-coordinate of the intersection point is rounded to the nearest pixel boundary to obtain the updated intersection point. The longer of the two diagonals formed by the updated intersection is determined, and the gain value of the corresponding pixel is determined according to the division ratio of the area of each pixel in the row by the determined diagonal. The output pixel value after gradient processing is determined based on the input pixel value and the gain value. The step of obtaining the intersection points of the upper and lower boundaries of a row of pixels with the two edge curves of the region to be gradient includes: Obtain the equations for the upper and lower boundaries of the pixels in this row, resulting in two straight line equations; Obtain the equations of the two edge curves of the region to be gradually changed, thus obtaining two curve equations; Based on the two straight line equations and the two curve equations, calculate the coordinates of the intersection points of the upper and lower boundaries of the row of pixels with the two edge curves of the region to be gradient.
2. The processing method according to claim 1, wherein, The obtained two curve equations include: The equations of the two curves are obtained directly from the predetermined curve definitions.
3. The processing method according to claim 1, wherein, The two curve equations obtained include: Obtain the equation of one edge curve of the region to be gradiented, and calculate the equation of the other edge curve of the region to be gradiented based on the obtained equation and a preset gradient width.
4. The processing method according to claim 3, wherein, Based on the obtained equation, the equation for calculating another edge curve of the region to be gradient is calculated according to the preset gradient width, including: calculating the equation of the curve obtained by translating the edge curve corresponding to the obtained equation by the preset gradient width.
5. The processing method according to claim 3, wherein, Based on the obtained equation, the equation for calculating another edge curve of the region to be gradient is calculated according to the preset gradient width, including: calculating the equation of the curve obtained by scaling the preset gradient width along the radius of curvature of the edge curve corresponding to the obtained equation.
6. The processing method according to claim 1, wherein, The gain value of the corresponding pixel is determined based on the proportion of the area of each pixel in the row divided by the determined diagonal, including: determining the gain value of the pixel as the ratio of the area of the pixel on one side of the graphic of the determined diagonal to the pixel area. Determining the output pixel value after gradient processing based on the input pixel value of a pixel and the gain value includes: adding the product of the input pixel value of the pixel and the gain value to the product of the input pixel value of the background and the difference between 1 and the gain value, to obtain the output pixel value of the pixel.
7. The processing method according to claim 1, wherein, The gain value of the corresponding pixel is determined based on the proportion of the area of each pixel in the row that is divided by the determined diagonal, including: determining the ratio of the area of a pixel in the row on the background side of the determined diagonal to the pixel area as the gain value of the pixel. Determining the output pixel value after gradient processing based on the input pixel value of a pixel and the gain value includes: adding the product of the input pixel value of the pixel and the difference between 1 and the gain value to the product of the input pixel value of the background and the gain value to obtain the output pixel value of the pixel.
8. A method for determining the gain value in curve edge gradient processing, comprising: Obtain the intersection points of the upper and lower boundaries of a row of pixels with the two edge curves of the area to be gradientd; The x-coordinate of the intersection point is rounded to the nearest pixel boundary to obtain the updated intersection point. The longer of the two diagonals formed by the updated intersection points is determined, and the gain value of the corresponding pixel in the gradient processing is determined based on the proportion of the area of each pixel in the row that the determined diagonal divides. The step of obtaining the intersection points of the upper and lower boundaries of a row of pixels with the two edge curves of the region to be gradient includes: Obtain the equations for the upper and lower boundaries of the pixels in this row, resulting in two straight line equations; Obtain the equations of the two edge curves of the region to be gradually changed, thus obtaining two curve equations; Based on the two straight line equations and the two curve equations, calculate the coordinates of the intersection points of the upper and lower boundaries of the row of pixels with the two edge curves of the region to be gradient.
9. The determining method according to claim 8, wherein, The two curve equations obtained include: The equations of the two curves are obtained directly from the predetermined curve definitions.
10. The determining method according to claim 8, wherein, The two curve equations obtained include: Obtain the equation of one edge curve of the region to be gradiented, and calculate the equation of the other edge curve of the region to be gradiented based on the obtained equation and a preset gradient width.
11. The determining method according to claim 10, wherein, Based on the obtained equation, the equation for calculating another edge curve of the region to be gradient is calculated according to the preset gradient width, including: calculating the equation of the curve obtained by translating the edge curve corresponding to the obtained equation by the preset gradient width.
12. The determining method according to claim 10, wherein, Based on the obtained equation, the equation for calculating another edge curve of the region to be gradient is calculated according to the preset gradient width, including: calculating the equation of the curve obtained by scaling the preset gradient width along the radius of curvature of the edge curve corresponding to the obtained equation.
13. An electronic device, comprising: A processor, a memory, and a program stored in the memory and executable on the processor, wherein the program, when executed by the processor, implements the steps of the processing method of any one of claims 1-7 or the steps of the determining method of any one of claims 8-12.
14. A computer-readable storage medium storing a computer program or instructions that, when executed by a processor, implement the steps of the processing method as claimed in any one of claims 1-7 or the steps of the determining method as claimed in any one of claims 8-12.
Citation Information
Patent Citations
Image processing method of display panel
CN109192126A
Gradient image generation method and device and image signal generator
CN114463344A