Image processing method, device, terminal equipment and storage medium

By dividing the rectangular image into multiple areas and establishing a rectangular coordinate system, and only performing calculations on pixels within the rectangular area, the problem of large computational load of rectangular image processing in the existing technology is solved, and the device performance is improved.

CN113554547BInactive Publication Date: 2024-09-10BEIJING XIAOMI MOBILE SOFTWARE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010333520.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-04-24
Publication Date
2024-09-10
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

In the prior art, when rounding corners of a rectangular image, a large amount of calculation is required, resulting in high GPU consumption and affecting device performance.

Method used

The image is divided into multiple areas based on the right angles of the image, and a rectangular coordinate system is established in each area. Only the pixels located in the first quadrant of the rectangular coordinate system are operated, thereby filtering out useless operations and reducing the amount of calculation.

Benefits of technology

It effectively reduces the power consumption of the GPU, improves the performance of the terminal device, and improves the efficiency of image processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113554547B
    Figure CN113554547B
Patent Text Reader

Abstract

The present application discloses an image processing method, device, terminal device and storage medium. The method is applied to an image with a rectangular shape, including: dividing the image into multiple regions based on the right angle of the image, and establishing a corresponding rectangular coordinate system for the right angle in each region; wherein, the straight lines parallel to the rectangular sides forming the right angle and having a first distance and a second distance from the rectangular sides are respectively used as the first axis and the second axis of the rectangular coordinate system, the intersection of the first axis and the second axis is used as the origin of the rectangular coordinate system, and the quadrant where the right angle is located is used as the first quadrant of the corresponding rectangular coordinate system; determining whether the pixel point in the image is located in the first quadrant of the rectangular coordinate system; if it is determined that the pixel point is located in the first quadrant of the rectangular coordinate system, the pixel point is operated; otherwise, the pixel point is not operated. The method greatly reduces the amount of calculation, effectively reduces the power consumption of the GPU, and improves the performance of the terminal device.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer software technology, and in particular to an image processing method, apparatus, terminal device and storage medium. Background Art

[0002] Before displaying an image, it may be necessary to perform certain image processing operations. For example, for an image with a rectangular shape, considering that when a terminal device with a rounded screen is used to display the image, the right angles of the image will not match the rounded corners of the screen, it is usually necessary to perform corresponding rounding processing on the rectangular image before displaying it so that the displayed image shape matches the rounded screen. In the prior art, when performing rounding processing on a rectangular image, it is necessary to perform corresponding operations on each pixel in the image to determine whether the pixel is within the rounded corner to be matched, so as to determine whether to perform corresponding rounding processing on the pixel. Therefore, this method requires a particularly large amount of operations, which causes a great loss to the graphics processing unit (GPU), which also affects the overall performance of the device. Summary of the invention

[0003] In view of the above-mentioned defects or deficiencies in the prior art, the present application proposes an image processing method, apparatus, terminal device and storage medium to solve the problems in the prior art of large amount of computation required for image processing of rectangular images, large loss to GPU and affecting device performance.

[0004] The first aspect of the present application provides an image processing method, which is applied to an image with a rectangular shape, including: dividing the image into multiple areas based on the right angle of the image, and establishing a corresponding rectangular coordinate system for the right angle in each area; wherein, straight lines parallel to the rectangular sides constituting the right angle and at a first distance and a second distance from the rectangular sides are respectively used as the first axis and the second axis of the rectangular coordinate system, and the intersection of the first axis and the second axis is used as the origin of the rectangular coordinate system, and in each quadrant of the rectangular coordinate system, the quadrant where the right angle is located is used as the first quadrant of the corresponding rectangular coordinate system; determining whether a pixel point in the image is located in the first quadrant of the rectangular coordinate system; if it is determined that the pixel point is located in the first quadrant of the rectangular coordinate system, then operating on the pixel point; otherwise, not operating on the pixel point.

[0005] In one embodiment, determining whether a pixel point in the image is located in the first quadrant of the rectangular coordinate system includes: establishing an image coordinate system and determining the center point of the image; wherein a vertex of a right angle of the image is used as the origin of the image coordinate system, and two rectangular sides forming the right angle are used as the positive semi-axes of the first axis and the second axis of the image coordinate system; calculating the relative position coordinates of the pixel point relative to the center point; calculating the absolute position coordinates of the pixel point relative to the center point based on the relative position coordinates; and determining whether the pixel point is located in the first quadrant of the rectangular coordinate system according to the absolute position coordinates.

[0006] In one embodiment, the calculation of the relative position coordinates of the pixel point relative to the center point includes: obtaining the position coordinates of the pixel point and the center point in the image coordinate system; subtracting the position coordinates of the pixel point from the position coordinates of the center point to obtain the relative position coordinates of the pixel point relative to the center point; the calculation of the absolute position coordinates of the pixel point relative to the center point based on the relative position coordinates includes: taking the absolute value of the relative position coordinates, and subtracting the absolute value of the relative position coordinates from the position coordinates of the center point to obtain the absolute position coordinates of the pixel point relative to the center point; the determination of whether the pixel point is located in the first quadrant of the rectangular coordinate system based on the absolute position coordinates includes: adding the values ​​of the absolute position coordinates in the horizontal and vertical directions to the second distance and the first distance respectively to obtain the coordinate value of the pixel point in the corresponding rectangular coordinate system, and if the coordinate value is a positive value, it is determined that the pixel point is located in the first quadrant of the rectangular coordinate system.

[0007] In one embodiment, the operation on the pixel point includes: substituting the coordinate value of the pixel point in the corresponding rectangular coordinate system into a processing formula for calculation, and determining whether the pixel point is located in the area defined by the curve represented by the processing formula.

[0008] A second aspect of the present application provides an image processing device, which is applied to an image with a rectangular shape, and includes: a rectangular coordinate system establishment module, which is configured to divide the image into multiple areas based on the right angle of the image, and establish a corresponding rectangular coordinate system for the right angle in each area; wherein straight lines parallel to the rectangular sides constituting the right angle and respectively at a first distance and a second distance from the rectangular sides are used as the first axis and the second axis of the rectangular coordinate system, respectively, and the intersection of the first axis and the second axis is used as the origin of the rectangular coordinate system, and in each quadrant of the rectangular coordinate system, the quadrant where the right angle is located is used as the first quadrant of the corresponding rectangular coordinate system; a determination module, which is configured to determine whether a pixel point in the image is located in the first quadrant of the rectangular coordinate system; and a calculation module, which is configured to perform calculations on the pixel point if it is determined that the pixel point is located in the first quadrant of the rectangular coordinate system; otherwise, the pixel point is not calculated.

[0009] In one embodiment, the determination module includes: an image coordinate system establishment unit, configured to establish an image coordinate system and determine the center point of the image; wherein a right-angled vertex of the image is used as the origin of the image coordinate system, and two rectangular sides forming the right angle are used as the positive semi-axes of the first axis and the second axis of the image coordinate system; a first calculation unit, configured to calculate the relative position coordinates of the pixel point relative to the center point; a second calculation unit, configured to calculate the absolute position coordinates of the pixel point relative to the center point based on the relative position coordinates; and a determination unit, configured to determine whether the pixel point is located in the first quadrant of the rectangular coordinate system according to the absolute position coordinates.

[0010] In one embodiment, the first calculation unit includes: an acquisition subunit, configured to acquire the position coordinates of the pixel point and the center point in the image coordinate system; a calculation subunit, configured to subtract the position coordinates of the pixel point from the position coordinates of the center point to obtain the relative position coordinates of the pixel point relative to the center point; the second calculation unit is configured to: take the absolute value of the relative position coordinates, and subtract the absolute value of the relative position coordinates from the position coordinates of the center point to obtain the absolute position coordinates of the pixel point relative to the center point; the determination unit is configured to: add the horizontal and vertical values ​​of the absolute position coordinates to the second distance and the first distance respectively to obtain the coordinate value of the pixel point in the corresponding rectangular coordinate system, and if the coordinate value is a positive value, it is determined that the pixel point is located in the first quadrant of the rectangular coordinate system.

[0011] In one embodiment, the calculation module is configured to: substitute the coordinate value of the pixel point in the corresponding rectangular coordinate system into the processing formula for calculation, and determine whether the pixel point is located in the area defined by the curve represented by the processing formula.

[0012] A third aspect of the present application provides a terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements any of the above methods when executing the program.

[0013] A fourth aspect of the present application provides a computer storage medium having a computer program stored thereon, wherein the program implements any of the above methods when executed by a processor.

[0014] In the image processing method provided in the embodiment of the present application, for a rectangular image, the image is first divided into multiple regions based on the right angles of the image, a corresponding rectangular coordinate system is established for the right angle in each region, and the quadrant where the right angle is located is used as the first quadrant of the corresponding rectangular coordinate system, and then it is determined whether the pixel points in the image are located in the first quadrant of the rectangular coordinate system, and finally it is determined whether to perform further operations on the pixel points to be processed based on the determination result. In other words, the embodiment of the present application only performs further operations on the pixel points that are determined to be located in the right angle area that may affect the image display after judgment, and does not perform operations on the pixel points in other areas of the image that will not affect the display of the right angle area. These areas are larger in area than the right angle area of ​​the image and contain more pixels. Therefore, in this way, useless operations of a large number of pixel points can be filtered out, which greatly reduces the amount of calculation, effectively reduces the power consumption of the GPU, and improves the performance of the terminal device. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] Other features, objects and advantages of the present application will become more apparent by reading the detailed description of non-limiting embodiments made with reference to the following drawings:

[0016] Figure 1 Shown is a flow chart of an image processing method provided by an embodiment of the present application;

[0017] Figure 2 FIG. 1 is a schematic diagram of establishing a coordinate system in an image to be processed in an image processing method provided by an embodiment of the present application;

[0018] Figure 3 Shown is a flow chart of an image processing method provided by another embodiment of the present application;

[0019] Figure 4 Shown is a schematic diagram of a display image to be formed after being processed by an image processing method provided by an embodiment of the present application;

[0020] Figure 5 FIG. 1 is a schematic diagram of the structure of an image processing device provided by an embodiment of the present application;

[0021] Figure 6 FIG. 1 is a schematic diagram showing the structure of a determination module in an image processing device provided in an embodiment of the present application;

[0022] Figure 7 The figure is a schematic diagram of the structure of a computer system of a server or terminal device suitable for implementing an embodiment of the present application. DETAILED DESCRIPTION

[0023] The present application will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the relevant inventions, rather than to limit the inventions. It should also be noted that, for ease of description, only the parts related to the invention are shown in the accompanying drawings.

[0024] The words "first", "second" and similar words used in this application do not indicate any order, quantity or importance, but are only used to distinguish different parts. The words "include" or "comprises" and similar words mean that the elements before the word include the elements listed after the word, and do not exclude the possibility of including other elements. "Up", "down" and the like are only used to indicate relative positional relationships. When the absolute position of the described object changes, the relative positional relationship may also change accordingly.

[0025] In the present application, when a specific component is described as being located between a first component and a second component, there may or may not be an intermediate component between the specific component and the first component or the second component. When a specific component is described as being connected to other components, the specific component may be directly connected to the other components without an intermediate component, or may not be directly connected to the other components but have an intermediate component.

[0026] All terms (including technical terms or scientific terms) used in this application have the same meaning as those understood by ordinary technicians in the field to which this application belongs, unless otherwise specifically defined. It should also be understood that terms defined in general dictionaries should be interpreted as having a meaning consistent with their meaning in the context of the relevant technology, and should not be interpreted in an idealized or extremely formal sense, unless explicitly defined herein.

[0027] Technologies, methods, and equipment known to ordinary technicians in the relevant art may not be discussed in detail, but where appropriate, the technologies, methods, and equipment should be considered part of the specification.

[0028] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0029] Figure 1 FIG. 1 is a flow chart of an image processing method provided by an embodiment of the present application. The method can be applied to images with a rectangular shape, such as Figure 1 As shown, the method comprises the following steps:

[0030] S101, dividing an image into a plurality of regions based on the right angles of the image, and establishing a corresponding right angle coordinate system in each region for the right angle.

[0031] Here, the multiple regions correspond to the multiple right angles of the rectangular image, and in each region, a rectangular coordinate system is established for the right angles in the region.

[0032] like Figure 2 As shown, based on the four right angles of the rectangular image 1, the rectangular image 1 is divided into four regions A, B, C and D. In each region, there is a rectangular coordinate system corresponding to the region and the right angle in the region. Specifically, the four rectangular coordinate systems x1o1y1, x2o2y2, x3o3y3 and x4o4y4 correspond to the four regions A, B, C and D and the right angles in their respective regions.

[0033] In each rectangular coordinate system, straight lines parallel to the rectangular sides forming the right angle and at a first distance and a second distance from the rectangular sides are respectively used as the first axis and the second axis of the rectangular coordinate system, and the intersection of the first axis and the second axis is used as the origin of the rectangular coordinate system. In each quadrant of the rectangular coordinate system, the quadrant where the right angle is located is used as the first quadrant of the corresponding rectangular coordinate system.

[0034] The following is a detailed explanation of the establishment of the rectangular coordinate system, taking the rectangular coordinate system x2o2y2 as an example. Figure 2 As shown, the right angle 13 is formed by the intersection of the rectangular sides 11 and 12, and the straight line o2x2 parallel to the rectangular side 11 and the first distance a1 from the transverse rectangular side 11 is used as the first axis of the rectangular coordinate system x2o2y2, and the straight line o2y2 parallel to the rectangular side 12 and the second distance a2 from the longitudinal rectangular side 12 is used as the second axis of the rectangular coordinate system x2o2y2. The intersection o2 of the straight lines o2x2 and o2y2 is used as the origin of the rectangular coordinate system x2o2y2. In each quadrant formed by the rectangular coordinate system x2o2y2, the quadrant where the right angle 13 is located is used as the first quadrant of the rectangular coordinate system x2o2y2. Here, the first axis and the second axis can specifically be the x-axis and y-axis of the rectangular coordinate system.

[0035] In this way, when a method similar to the above-mentioned rectangular coordinate system x2o2y2 is used to establish the right angle in each area, a rectangular coordinate system x1o1y1 corresponding to area A and right angle 14, a rectangular coordinate system x3o3y3 corresponding to area C and right angle 15, and a rectangular coordinate system x4o4y4 corresponding to area D and right angle 16 can be formed, and the first quadrant of the rectangular coordinate system in each area is the quadrant where the right angle in the area is located.

[0036] It should be noted that the first distance a1 and the second distance a2 may be the same or different. For example, when the first distance a1 and the second distance a2 are different, the area surrounded by the first axis, the second axis and the rectangular sides of the corresponding area of ​​the rectangular coordinate system is a rectangle with unequal sides; when the first distance a1 and the second distance a2 are the same, the area surrounded by the first axis, the second axis and the rectangular sides of the corresponding area of ​​the rectangular coordinate system is a square. In other words, the shape and size of the area defined by the first quadrant of the rectangular coordinate system in the rectangular image 1 are determined by the first distance a1 and the second distance a2. The specific values ​​of the first distance a1 and the second distance a2 can be set differently according to actual conditions and specific needs, and this application does not limit this.

[0037] S102, determining whether a pixel point in the image is located in the first quadrant of a rectangular coordinate system.

[0038] Because a corresponding rectangular coordinate system has been established for each right angle of the rectangular image 1 in step S101, and the quadrant where the right angle is located is set as the first quadrant of the rectangular coordinate system, by determining whether the pixel point is located in the first quadrant of the rectangular coordinate system in this step, it is also determined whether the pixel point to be processed is located in the rectangular area of ​​the rectangular image 1. The rectangular area can be understood as an edge area near the right angle. In the embodiment of the present application, the rectangular area is the area defined by the first quadrant of the rectangular coordinate system in the rectangular image. As mentioned above, the size of the area is determined by the first distance a1 and the second distance a2.

[0039] S103: If it is determined that the pixel point is located in the first quadrant of the rectangular coordinate system, then operation is performed on the pixel point; otherwise, no operation is performed on the pixel point.

[0040] If it is determined that the pixel point is located in the first quadrant of the rectangular coordinate system, it is also determined that the pixel point is located in the rectangular area that may affect the image display. Further operations are then performed on the pixel point, such as performing corresponding operations on the pixel point to further determine whether it is located within the rounded corner to be matched by the rectangular image, within the bevel formed after removing the right angle, etc., and then based on this result, it is determined whether to take further image processing operations on the pixel point, for example, making the pixel point outside the rounded corner area transparent, etc.; if it is determined that the pixel point is not located in the first quadrant of the rectangular coordinate system, it is also determined that the pixel point is located in the central area of ​​the image or the edge area far from the right angle, and it has no effect on the display of the rectangular area of ​​the image, so there is no need to perform further operations on the pixel point.

[0041] Similarly, the embodiments of the present application are also applicable to images of other shapes, as long as the images are symmetrical with respect to two vertical axes.

[0042] In the image processing method provided in the embodiment of the present application, for a rectangular image, the image is first divided into multiple regions based on the right angles of the image, a corresponding rectangular coordinate system is established for the right angle in each region, and the quadrant where the right angle is located is used as the first quadrant of the corresponding rectangular coordinate system, and then it is determined whether the pixel points in the image are located in the first quadrant of the rectangular coordinate system, and finally it is determined whether to perform further operations on the pixel points to be processed based on the determination result. In other words, the embodiment of the present application only performs further operations on the pixel points that are determined to be located in the right angle area that may affect the image display after judgment, and does not perform operations on the pixel points in other areas of the image that will not affect the display of the right angle area. These areas are larger in area than the right angle area of ​​the image and contain more pixels. Therefore, in this way, useless operations of a large number of pixel points can be filtered out, which greatly reduces the amount of calculation, effectively reduces the power consumption of the GPU, and improves the performance of the terminal device.

[0043] Figure 3 FIG. 2 is a flowchart of an image processing method provided by another embodiment of the present application. Figure 3 As shown, the method comprises the following steps:

[0044] S301, dividing the image into multiple regions based on the right angles of the image, and establishing a corresponding right angle coordinate system in each region for the right angle.

[0045] This step is similar to step S101 in the above embodiment and will not be described again here.

[0046] S302, establishing an image coordinate system and determining the center point of the image.

[0047] Specifically, a vertex of a right angle of the image is used as the origin of the image coordinate system, and two rectangular sides forming the right angle are used as the positive semi-axes of the first axis and the second axis of the image coordinate system.

[0048] For example, the upper left corner of the image is used as the origin of the image coordinate system, and the upper and left sides of the image are used as the positive semi-axes of the first and second axes of the image coordinate system, respectively. The first axis and the second axis can be the x-axis and y-axis of the image coordinate system, respectively, that is, the upper left corner of the image is used as the origin of the image coordinate system, and the right and downward directions are the positive directions of the x-axis and the y-axis, respectively. In the following description, it is assumed that the upper left corner of the image is used as the origin of the image coordinate system, and the upper and left sides of the image are used as the positive semi-axes of the first and second axes of the image coordinate system, respectively.

[0049] like Figure 2 As shown, assuming that the resolution of image 1 is 1080*2340, when establishing the image coordinate system for image 1, the upper left corner O' point of image 1 is used as the origin of the image coordinate system, and the upper edge 11 and the left edge 17 of image 1 are respectively used as the positive directions of the x-axis and the y-axis. Then, the coordinates of the upper right corner point M of image 1 are (1080, 0), the coordinates of the lower left corner point N are (0, 2340), the coordinates of the lower right corner point Q are (1080, 2340), and the center point of image 1 is point P with coordinates (540, 1170).

[0050] S303, calculating the relative position coordinates of the pixel point with respect to the center point.

[0051] In one embodiment, step S303 specifically includes: obtaining the position coordinates of the pixel point and the center point in the image coordinate system; subtracting the position coordinates of the pixel point from the position coordinates of the center point to obtain the relative position coordinates of the pixel point relative to the center point. That is, through step S303, the position coordinates of the pixel point in the image coordinate system are converted into the coordinate values ​​of the pixel point in the coordinate system with the center point as the origin and the positive directions of the x-axis and the y-axis to the right and downward from the center point respectively.

[0052] Taking the pixel point H in image 1 as an example of the pixel point to be processed, first, the position coordinates of the pixel point H and the center point P in the image coordinate system are obtained as (80, 60) and (540, 1170) respectively. After subtracting the position coordinates of the pixel point H from the center point P, the relative position coordinates of the pixel point H relative to the center point P are obtained (-460, -1110), that is, the coordinate value of the pixel point H in the coordinate system with the center point P as the origin and the positive directions of the x-axis and y-axis to the right and downward from the center point P respectively is (-460, -1110).

[0053] S304: Calculate the absolute position coordinates of the pixel point relative to the center point based on the relative position coordinates.

[0054] Specifically, the absolute value of the relative position coordinates calculated in step S303 may be taken, and the absolute value of the relative position coordinates may be subtracted from the position coordinates of the center point to obtain the absolute position coordinates of the pixel point relative to the center point.

[0055] That is, step S304 first converts the position coordinates of the pixel point in the image coordinate system into the coordinate value of the pixel point in the first quadrant (which can be understood as area D in the image) in the coordinate system with the center point as the origin and the positive directions of the x-axis and y-axis to the right and downward from the center point respectively. After subtracting the coordinate value from the position coordinate of the center point, the coordinate value is further converted into the coordinate value of the pixel point in the coordinate system with the lower right corner (point Q) of image 1 as the origin and the positive directions of the x-axis and y-axis to the right and downward from point Q respectively.

[0056] Taking pixel point H as an example, the absolute value of the relative position coordinates (-460, -1110) of pixel point H relative to the center point P is taken to obtain (460, 1110), that is, the position coordinates of pixel point H in the image coordinate system are converted to the coordinate values ​​in the first quadrant (area D) in the coordinate system with the center point P as the origin and the positive directions of the x-axis and y-axis to the right and downward from the center point P respectively (460, 1110).

[0057] After subtracting the absolute value from the position coordinates of the center point P (540, 1170), we can get the absolute position coordinates (-80, -60) of the pixel point H relative to the center point P, that is, the coordinate value of the pixel point H in the coordinate system with point Q as the origin and the positive directions of the x-axis and y-axis to the right and downward from point Q respectively.

[0058] S305: Determine whether the pixel point is located in the first quadrant of the rectangular coordinate system according to the absolute position coordinates.

[0059] In an embodiment of the present application, the horizontal and vertical values ​​of the absolute position coordinates obtained in step S304 may be added to the second distance and the first distance respectively to obtain the coordinate value of the pixel point in the corresponding rectangular coordinate system.

[0060] It can be understood that the rectangular coordinate system x4o4y4 established in step S301 is obtained by translating the coordinate system with point Q as the origin and the positive directions of the x-axis and y-axis from point Q to the right and downward respectively to the left by the second distance a2 (the distance between the y-axis of the rectangular coordinate system and the longitudinal side of the right angle corresponding to the rectangular coordinate system) and translating the first distance a1 (the distance between the x-axis of the rectangular coordinate system and the transverse side of the right angle corresponding to the rectangular coordinate system) upward, and the coordinate value of the pixel point H obtained in step S304 in the coordinate system with point Q as the origin and the positive directions of the x-axis and y-axis from point Q to the right and downward respectively is added to the second distance a2 and the first distance to obtain the coordinate value of the pixel point H in the rectangular coordinate system x4o4y4. If the coordinate value is a positive value, it is determined that the pixel point is located in the first quadrant of the rectangular coordinate system.

[0061] The absolute position coordinates (-80, -60) of the pixel point H relative to the center point P are obtained from step S304, and the values ​​of the absolute position coordinates in the horizontal and vertical directions are -80 and -60 respectively. Assume that the second distance a2 and the first distance a1 are taken as 100 and 80 respectively when the rectangular coordinate system is established in the above step S301, and they are added to the values ​​of the absolute position coordinates of the pixel point H relative to the center point P in two directions, and finally the coordinate value of the pixel point H in its corresponding rectangular coordinate system x1o1y1 is (20, 20).

[0062] like Figure 2 As shown, since the pixel point H is located in the A area in the image 1, the rectangular coordinate system corresponding to the A area is x1o1y1, so the rectangular coordinate system corresponding to the pixel point H is also x1o1y1. To determine whether the pixel point H is located in the first quadrant of the rectangular coordinate system, it is sufficient to determine whether the pixel point H is located in the first quadrant of its corresponding rectangular coordinate system x1o1y1. According to steps S303-S305, the coordinate value of the pixel point H in its corresponding rectangular coordinate system x1o1y1 is (20, 20), that is, the values ​​on the x-axis and y-axis of the rectangular coordinate system x1o1y1 are both positive values, indicating that the pixel point H is located in the first quadrant of the rectangular coordinate system x1o1y1. In other words, the pixel point H is located in the rectangular area that may affect the image display.

[0063] Taking the pixel point G in the C region and the pixel point K in the D region as an example, it is determined through steps S303 - S305 whether the pixel point G and the pixel point K are located in the first quadrant of the rectangular coordinate system.

[0064] Assuming that the first distance a1 and the second distance a2 are still 100 and 80, the position coordinates of the pixel point G in the image coordinate system are (80, 2240), and the position coordinates of the pixel point G and the center point P in the image coordinate system (540, 1170) are subtracted to obtain the relative position coordinates of the pixel point G relative to the center point P (-460, 1070); the absolute value of the relative position coordinates of the pixel point G relative to the center point P (-460, 1070) is taken to obtain (460, 1070), and the absolute value is added to the position coordinates of the center point P ( 540, 1170), the absolute position coordinates (-80, -100) of the pixel point G relative to the center point P can be obtained; the horizontal and vertical values ​​of the absolute position coordinates -80 and -100 are added to the second distance a2 (100) and the first distance a1 (80) respectively to obtain the coordinate value (20, -20) of the pixel point G in the corresponding rectangular coordinate system x3o3y3, which is located in the fourth quadrant rather than the first quadrant in the rectangular coordinate system x3o3y3, indicating that the pixel point G will not affect the display of the rectangular area of ​​​​the image 1.

[0065] Assume that the position coordinates of the pixel point K in the image coordinate system are (1000, 2280), and after subtracting the position coordinates (540, 1170) of the pixel point K from the center point P in the image coordinate system, the relative position coordinates of the pixel point K relative to the center point P are obtained to be (460, 1110); after taking the absolute value of the relative position coordinates (460, 1110) of the pixel point K relative to the center point P, (460, 1110) is obtained, and after subtracting the absolute value from the position coordinates (540, 1170) of the center point P, the absolute position coordinates of the pixel point K relative to the center point P are obtained to be (-80, -60); the horizontal and vertical values ​​of the absolute position coordinates -80 and -60 are added to the second distance a2 (100) and the first distance a1 (80) respectively to obtain the coordinate value (20, 20) of the pixel point K in the corresponding rectangular coordinate system x4o4y4, which is located in the first quadrant of the rectangular coordinate system x4o4y4.

[0066] In the embodiment of the present application, the position coordinates of the pixel point to be processed are first subtracted from the position coordinates of the center point, that is, the position coordinates of the pixel point in the image coordinate system are converted into the coordinate value of the pixel point in the coordinate system with the center point as the origin and the positive directions of the x-axis and y-axis to the right and downward from the center point respectively; then, by taking the absolute value of the coordinate value, the coordinate value of the pixel point in the first quadrant of the coordinate system with the center point as the origin and the positive directions of the x-axis and y-axis to the right and downward from the center point respectively, that is, the absolute coordinate value is obtained; then, after subtracting the absolute coordinate value from the position coordinate of the center point, the coordinate value of the pixel point in the coordinate system with point Q as the origin and the positive directions of the x-axis and y-axis to the right and downward from point Q respectively is obtained; finally, the coordinate value of the pixel point in the rectangular coordinate system x4o4y4 is obtained by coordinate translation. Since this method performs coordinate transformation based on the center point of the image, any pixel point in any area of ​​the image can correspond to its coordinate value in the rectangular coordinate system x4o4y4 at the lower right corner of the image through coordinate transformation and absolute value taking in steps S303-S305. This method is simple to calculate, suitable for the calculation of pixel points at any position in the image, and has strong versatility.

[0067] S306: If it is determined that the pixel point is located in the first quadrant of the rectangular coordinate system, then the pixel point is operated; otherwise, the pixel point is not operated.

[0068] Specifically, the coordinate value of the pixel point in the corresponding rectangular coordinate system may be substituted into the processing formula for calculation to determine whether the pixel point is located within the area defined by the curve represented by the processing formula.

[0069] The processing formula may be a rounded corner processing formula, a bevel corner processing formula, etc., which is not limited in this application. For example, when the processing formula is a rounded corner processing formula, the coordinate value of the pixel point in the corresponding rectangular coordinate system may be substituted into the rounded corner processing formula for calculation, thereby determining whether the pixel point is within the area defined by the arc curve represented by the rounded corner processing formula.

[0070] Assume that we want to process image 1 to be displayed as Figure 4 When the pixel to be processed is determined to be located in the first quadrant of the rectangular coordinate system, the coordinate value of the pixel point in the corresponding rectangular coordinate system can be substituted into the rounded corner processing formula (such as ) is calculated, if The representative pixel is located at Figure 2 The inside of the fillet 18 shown, i.e. the fillet processing formula Within the area defined by the arc curve represented by , no further image processing operation may be performed on the pixel point; if The representative pixel is located at Figure 2 The outer edge or edge of the fillet 18 shown, i.e. the fillet processing formula On the represented arc curve or outside the area defined by the curve, it is necessary to perform further image processing on the pixel point, such as making the pixel point transparent so that it is not displayed.

[0071] exist In the above, a and b may be equal or unequal. When a and b are unequal, the image 1 may be processed into an elliptical image with rounded corners through the above steps. When a and b are equal, the image 1 may be processed into a circular image with rounded corners through the above steps. A person skilled in the art may set the second distance a2 and the first distance a1 according to the pre-obtained rounded corner parameters, such as the arc and radius value (a, b) of the rounded corner. In this specific embodiment, the second distance a2 may be equal to the parameter a, and the first distance a1 may be equal to the parameter b.

[0072] For another example, when the processing formula is an oblique angle processing formula, the coordinate value of the pixel point in the corresponding rectangular coordinate system can be substituted into the corresponding oblique angle processing formula for calculation, so as to determine whether the pixel point is located in the area defined by the oblique line represented by the oblique angle processing formula. Similarly, the second distance a2 and the first distance a1 can be set according to the oblique angle to be obtained (the parameter of the oblique line equation).

[0073] In addition, the method of the present application is also applicable to processing right angles into other arbitrary shapes (such as irregular shapes). It is only necessary to substitute the coordinate values ​​of the pixel points in the corresponding rectangular coordinate system into the processing equation corresponding to the pre-formed shape for calculation.

[0074] In the image processing method provided in the embodiment of the present application, an image coordinate system is established with the upper left corner of the image as the origin, and the center point of the image is determined, and then the relative position coordinates and absolute position coordinates of the pixel point relative to the center point are calculated, so as to determine whether the pixel point is located in the first quadrant of the rectangular coordinate system. This method uses the center point of the image as the reference point, and can calculate the absolute position coordinates of any pixel point in the image relative to the center point by means of coordinate transformation. According to the absolute position coordinates, it can be determined whether the pixel point is located in the first quadrant of the corresponding rectangular coordinate system. The method is simple and effective, and can omit useless operations of a large number of pixel points, reduce the power consumption of the GPU, and improve the overall performance of the terminal device.

[0075] The embodiment of the present application also provides an image processing device, which can be applied to an image with a rectangular shape. Figure 5 FIG. 1 is a schematic diagram of the structure of an image processing device provided in an embodiment of the present application. Figure 5 As shown, the device 500 includes a rectangular coordinate system establishing module 510 , a determining module 520 and a computing module 530 .

[0076] The rectangular coordinate system establishing module 510 is configured to divide the image into a plurality of regions based on the rectangular angles of the image, and establish a corresponding rectangular coordinate system for the rectangular angles in each region.

[0077] Specifically, straight lines parallel to the rectangular sides forming the right angle and at a first distance and a second distance from the rectangular sides are respectively used as the first axis and the second axis of the rectangular coordinate system, and the intersection of the first axis and the second axis is used as the origin of the rectangular coordinate system. In each quadrant of the rectangular coordinate system, the quadrant where the right angle is located is used as the first quadrant of the corresponding rectangular coordinate system.

[0078] The determination module 520 is configured to determine whether a pixel point in the image is located in the first quadrant of the rectangular coordinate system.

[0079] The operation module 530 is configured to perform an operation on the pixel point if it is determined that the pixel point is located in the first quadrant of the rectangular coordinate system; otherwise, the operation is not performed on the pixel point.

[0080] In the image processing device provided in the embodiment of the present application, the rectangular coordinate system establishment module 510 first divides the rectangular image into multiple areas based on the right angles of the image, establishes a corresponding rectangular coordinate system for the right angle in each area, and uses the quadrant where the right angle is located as the first quadrant of the corresponding rectangular coordinate system, and then determines whether the pixel points in the image are located in the first quadrant of the rectangular coordinate system through the determination module 520, and finally the operation module 530 finally determines whether to perform further operations on the pixel points to be processed according to the determination result. In other words, the embodiment of the present application only performs further operation processing on the pixel points that are determined to be located in the right angle area that may affect the image display after judgment, and does not perform operations on the pixel points located in other areas of the image that will not affect the display of the right angle area, thereby filtering out useless operations of a large number of pixel points, greatly reducing the amount of calculation, effectively reducing the power consumption of the GPU, and improving the performance of the terminal device.

[0081] In one embodiment of the present application, Figure 6 As shown, the determination module 520 specifically includes an image coordinate system establishing unit 521 , a first calculating unit 522 , a second calculating unit 523 and a determination unit 524 .

[0082] The image coordinate system establishing unit 521 is configured to establish an image coordinate system and determine the center point of the image. Specifically, the upper left corner of the image is used as the origin of the image coordinate system, and the upper and left sides of the image are used as the positive semi-axes of the first and second axes of the image coordinate system.

[0083] The first calculation unit 522 is configured to calculate relative position coordinates of the pixel point relative to the center point.

[0084] In one embodiment, the first calculation unit 522 specifically includes: an acquisition subunit, configured to acquire the position coordinates of the pixel point and the center point in the image coordinate system; a calculation subunit, configured to subtract the position coordinates of the pixel point from the position coordinates of the center point to obtain the relative position coordinates of the pixel point relative to the center point.

[0085] The second calculation unit 523 is configured to calculate the absolute position coordinates of the pixel point relative to the center point based on the relative position coordinates.

[0086] In one embodiment, the second calculation unit 523 takes an absolute value of the relative position coordinates, and subtracts the absolute value of the relative position coordinates from the position coordinates of the center point to obtain the absolute position coordinates of the pixel point relative to the center point.

[0087] The determination unit 524 is configured to determine whether the pixel point is located in the first quadrant of the rectangular coordinate system according to the absolute position coordinates.

[0088] In one embodiment, the determination unit 524 adds the values ​​of the absolute position coordinates in the horizontal and vertical directions to the second distance and the first distance respectively to obtain the coordinate value of the pixel point in the corresponding rectangular coordinate system. If the coordinate value is a positive value, it is determined that the pixel point is located in the first quadrant of the rectangular coordinate system.

[0089] In one embodiment of the present application, the operation module 530 substitutes the coordinate value of the pixel point in the corresponding rectangular coordinate system into the processing formula for calculation to determine whether the pixel point is located in the area defined by the curve represented by the processing formula.

[0090] In the image processing device provided in the embodiment of the present application, the image coordinate system establishment unit 521 establishes the image coordinate system with the upper left corner of the image as the origin, and determines the center point of the image. The first calculation unit 522 and the second calculation unit 523 calculate the relative position coordinates and absolute position coordinates of the pixel point relative to the center point, and then the determination unit 524 determines whether the pixel point is located in the first quadrant of the rectangular coordinate system. This device uses the center point of the image as the reference point, and can calculate the absolute position coordinates of any pixel point in the image relative to the center point by coordinate transformation. According to the absolute position coordinates, it can be determined whether the pixel point is located in the first quadrant of the corresponding rectangular coordinate system. It is simple and effective, and can omit useless operations of a large number of pixel points, reduce the power consumption of the GPU, and improve the overall performance of the terminal device.

[0091] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0092] It should be understood that the modules recorded in the device 500 correspond to the various steps in the method described above. Therefore, the operations and features described above for the method are also applicable to the device 500 and the units contained therein, and will not be repeated here. The device 500 can be pre-implemented in a browser or other security application of an electronic device, or can be loaded into the browser or its security application of an electronic device by downloading or the like. The corresponding units in the device 500 can cooperate with the units in the electronic device to implement the solution of the embodiment of the present application.

[0093] The several modules or units mentioned in the above detailed description are not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into multiple modules or units to be embodied.

[0094] Reference below Figure 7 , which shows a schematic diagram of the structure of a computer system 100 of a server or terminal device suitable for implementing an embodiment of the present application.

[0095] like Figure 7 As shown, the computer system 100 includes a central processing unit (CPU) 101, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 102 or a program loaded from a storage part 108 into a random access memory (RAM) 103. In the RAM 103, various programs and data required for the operation of the system 100 are also stored. The CPU 101, the ROM 102, and the RAM 103 are connected to each other through a bus 104. An input / output (I / O) interface 105 is also connected to the bus 104.

[0096] The following components are connected to the I / O interface 105: an input section 106 including a keyboard, a mouse, etc.; an output section 107 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 108 including a hard disk, etc.; and a communication section 109 including a network interface card such as a LAN card, a modem, etc. The communication section 109 performs communication processing via a network such as the Internet. A drive 110 is also connected to the I / O interface 105 as needed. A removable medium 111, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 110 as needed, so that a computer program read therefrom is installed into the storage section 108 as needed.

[0097] In particular, according to an embodiment of the present application, the above reference flow chart Figure 1The described process can be implemented as a computer software program. For example, the present application includes a computer program product, which includes a computer program carried on a machine-readable medium, and the computer program contains program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 109, and / or installed from the removable medium 111. When the computer program is executed by the central processing unit (CPU) 101, the above-mentioned functions defined in the system of the present application are executed.

[0098] It should be noted that the computer-readable medium shown in the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0099] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to the various embodiments disclosed in the present application. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of the code, and the aforementioned module, program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0100] The units or modules involved in the embodiments described in the present disclosure may be implemented by software or hardware. The units or modules described may also be set in a processor, for example, it may be described as: a processor includes a rectangular coordinate system establishment module 510, a determination module 520, and an operation module 530. The names of these modules do not constitute a limitation on the units or modules themselves in some cases, for example, the rectangular coordinate system establishment module 510 may also be described as a "module for establishing a rectangular coordinate system".

[0101] As another aspect, the present application further provides a computer-readable storage medium, which may be included in the electronic device described in the above embodiment; or may exist independently without being assembled into the electronic device. The above computer-readable storage medium stores one or more programs, and when the above programs are used by one or more processors to execute the configuration method described in the present application.

[0102] For example, electronic devices can implement Figure 1 Shown: Step S101-Step S103.

[0103] The above description is only a preferred embodiment of the present application and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present application is not limited to the technical solution formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the aforementioned disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in this application (but not limited to) by each other to form a technical solution.

Claims

1. An image processing method, applied to an image having a rectangular shape, characterized in that: include: The image is divided into a plurality of regions based on the right angle of the image, and a corresponding rectangular coordinate system is established for the right angle in each region; wherein straight lines which are parallel to the rectangular sides forming the right angle and are respectively at a first distance and a second distance from the rectangular sides are used as the first axis and the second axis of the rectangular coordinate system, respectively, and the intersection of the first axis and the second axis is used as the origin of the rectangular coordinate system; in each quadrant of the rectangular coordinate system, the quadrant where the right angle is located is used as the first quadrant of the corresponding rectangular coordinate system, and the first distance and the second distance are different; Determining whether a pixel in the image is located in the first quadrant of the rectangular coordinate system; If it is determined that the pixel point is located in the first quadrant of the rectangular coordinate system, then the pixel point is operated; otherwise, the pixel point is not operated; Determining whether a pixel point in the image is located in the first quadrant of the rectangular coordinate system includes: Establishing an image coordinate system and determining the center point of the image; wherein a vertex of a right angle of the image is used as the origin of the image coordinate system, and two rectangular sides forming the right angle are used as the first axis and the positive semi-axis of the second axis of the image coordinate system; Calculating the relative position coordinates of the pixel point relative to the center point; Calculate the absolute position coordinates of the pixel point relative to the center point based on the relative position coordinates; It is determined according to the absolute position coordinates whether the pixel point is located in the first quadrant of the rectangular coordinate system, and the first distance and the second distance are both less than half of the width and length of the image.

2. The method according to claim 1, characterized in that The calculating the relative position coordinates of the pixel point relative to the center point includes: Obtaining position coordinates of the pixel point and the center point in the image coordinate system; Subtracting the position coordinates of the pixel point from the position coordinates of the center point to obtain the relative position coordinates of the pixel point relative to the center point; Calculating the absolute position coordinates of the pixel point relative to the center point based on the relative position coordinates includes: taking an absolute value of the relative position coordinates, and subtracting the absolute value of the relative position coordinates from the position coordinates of the center point to obtain the absolute position coordinates of the pixel point relative to the center point; The method of determining whether the pixel point is located in the first quadrant of the rectangular coordinate system based on the absolute position coordinates includes: adding the horizontal and vertical values ​​of the absolute position coordinates to the second distance and the first distance respectively to obtain the coordinate value of the pixel point in the corresponding rectangular coordinate system; if the coordinate value is a positive value, it is determined that the pixel point is located in the first quadrant of the rectangular coordinate system.

3. The method according to claim 1 or 2, characterized in that The performing operation on the pixel point comprises: Substitute the coordinate value of the pixel point in the corresponding rectangular coordinate system into the processing formula for calculation to determine whether the pixel point is located in the area defined by the curve represented by the processing formula.

4. An image processing device, applied to an image having a rectangular shape, characterized in that: include: a rectangular coordinate system establishment module, configured to divide the image into a plurality of regions based on the right angle of the image, and establish a corresponding rectangular coordinate system for the right angle in each region; wherein straight lines parallel to the rectangular sides forming the right angle and having a first distance and a second distance from the rectangular sides are respectively used as the first axis and the second axis of the rectangular coordinate system, and the intersection of the first axis and the second axis is used as the origin of the rectangular coordinate system; in each quadrant of the rectangular coordinate system, the quadrant where the right angle is located is used as the first quadrant of the corresponding rectangular coordinate system, and the first distance and the second distance are different; a determination module configured to determine whether a pixel point in the image is located in the first quadrant of the rectangular coordinate system; a calculation module configured to perform calculation on the pixel point if it is determined that the pixel point is located in the first quadrant of the rectangular coordinate system; otherwise, not perform calculation on the pixel point; The determination module comprises: An image coordinate system establishing unit is configured to establish an image coordinate system and determine the center point of the image; wherein a vertex of a right angle of the image is used as the origin of the image coordinate system, and two rectangular sides forming the right angle are used as the first axis and the positive semi-axis of the second axis of the image coordinate system; A first calculation unit is configured to calculate the relative position coordinates of the pixel point relative to the center point; A second calculation unit is configured to calculate the absolute position coordinates of the pixel point relative to the center point based on the relative position coordinates; The determination unit is configured to determine whether the pixel point is located in the first quadrant of the rectangular coordinate system according to the absolute position coordinates, and the first distance and the second distance are both less than half of the image width and length.

5. The device according to claim 4, characterized in that The first computing unit comprises: An acquisition subunit is configured to acquire position coordinates of the pixel point and the center point in the image coordinate system; a calculation subunit, configured to subtract the position coordinates of the pixel point from the position coordinates of the center point to obtain the relative position coordinates of the pixel point relative to the center point; The second calculation unit is configured to: take an absolute value of the relative position coordinates, and subtract the absolute value of the relative position coordinates from the position coordinates of the center point to obtain the absolute position coordinates of the pixel point relative to the center point; The determination unit is configured to: add the values ​​of the absolute position coordinates in the horizontal and vertical directions to the second distance and the first distance respectively to obtain the coordinate value of the pixel point in the corresponding rectangular coordinate system; if the coordinate value is a positive value, determine that the pixel point is located in the first quadrant of the rectangular coordinate system.

6. The device according to claim 4 or 5, characterized in that The operation module is configured to: substitute the coordinate value of the pixel point in the corresponding rectangular coordinate system into a processing formula for calculation, and determine whether the pixel point is located in a region defined by a curve represented by the processing formula.

7. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method according to any one of claims 1 to 3 is implemented.

8. A computer storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 3 is implemented.