Image processing method, image processor, electronic device, storage medium and product
By obtaining the centroid coordinates of primitive vertices and performing perspective correction, the calculation process of sampling point attribute values in image rendering is simplified, solving the problem of high computational complexity in existing technologies and improving computational efficiency and adaptability.
Patent Information
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- VERISILICON MICROELECTRONICS (SHANGHAI) CO LTD
- Filing Date
- 2024-12-16
- Publication Date
- 2026-06-25
AI Technical Summary
Existing technologies for obtaining attribute values from sampling points in image rendering involve high computational complexity, especially when multiple attributes need to be calculated, resulting in low computational efficiency.
By obtaining the centroid coordinates of primitive vertices relative to the initial primitive and performing perspective correction between clip space and screen space, the number of linear interpolation operations is reduced, the calculation process is simplified, and frequent conversions and repetitive calculations are avoided.
It reduces the complexity and computational load of calculating the attribute values of sampling points, improves the efficiency and adaptability of image processing, and is suitable for more application scenarios.
Smart Images

Figure CN2024139656_25062026_PF_FP_ABST
Abstract
Description
Image processing methods, image processors, electronic devices, storage media and products Technical Field
[0001] This application relates to the field of image processing technology, and more specifically, to an image processing method, an image processor, an electronic device, a storage medium, and a product. Background Technology
[0002] In computer graphics, before rendering (shading) any sampling point within a primitive, the attribute value of that sampling point (such as color, texture, etc.) is calculated, and then the attribute value is used to render the sampling point, making the rendering result more realistic and detailed.
[0003] Referring to Figure 1, in related technologies, the method for obtaining the attribute values of sampling points generally involves first obtaining the attribute values of primitive vertices in clip space, and then converting the primitive to screen space. Interpolation is then performed based on the attribute values of the primitive vertices and the centroid coordinates of the sampling points to obtain the attribute values of the sampling points. Taking a triangle primitive as an example, the above method requires at least one 3D linear interpolation and one 2D linear interpolation for any type of attribute value. When there are many types of attributes to be calculated, the above technical solution needs to perform multiple floating-point / fixed-point multiplication and addition operations to obtain the attribute values required for rendering, resulting in high computational complexity. Summary of the Invention
[0004] The purpose of this application is to provide an image processing method, image processor, electronic device, storage medium, and product to improve the computational complexity of the sampling point attribute value acquisition scheme.
[0005] In a first aspect, embodiments of this application provide an image processing method, the method comprising: obtaining first centroid coordinates of a first vertex relative to an initial primitive in an image frame; wherein the first vertex is a vertex of a first primitive located in a clipping space; the first primitive includes a new primitive generated after clipping the initial primitive, and / or the initial primitive without the clipping process; converting the first centroid coordinates to screen space, and obtaining second centroid coordinates of a second vertex relative to the initial primitive; wherein the second vertex is a vertex of a second primitive, and the second primitive is obtained by converting the first primitive to the screen space; obtaining third centroid coordinates of a sampling point relative to the second primitive; wherein the sampling point is a sampling point in the second primitive; obtaining fourth centroid coordinates of the sampling point relative to the initial primitive based on the second centroid coordinates and the third centroid coordinates; obtaining second attribute information of the sampling point based on the fourth centroid coordinates and first attribute information; wherein the first attribute information is attribute information of an initial vertex; the initial vertex is a vertex of the initial primitive; and rendering the sampling point based on the second attribute information.
[0006] In the implementation of the above scheme, on the one hand, based on the property that the sum of the barycentric coordinate components is one and invariant, for the primitive after clipping, the attribute values of the new vertices in the clipping space are no longer directly calculated. Instead, the barycentric coordinates of the new vertices after clipping relative to the initial primitive are calculated. In the screen space, the barycentric coordinates of the sampling point relative to the initial primitive are obtained based on the barycentric coordinates of the primitive vertices relative to the initial primitive. Finally, the attribute values of the sampling point are obtained based on the attribute values of the initial primitive vertices and the barycentric coordinates of the sampling point relative to the initial primitive. On the one hand, the above scheme reduces the number of linear interpolations, which is beneficial to improving computational efficiency. On the other hand, compared with the calculation schemes used in related technologies, the above scheme simplifies the calculation process and avoids frequent conversions and repeated calculations between the clipping space and the screen space, which is beneficial to improving computational efficiency.
[0007] In one implementation of the first aspect, the method further includes: determining whether the number of attribute types to be calculated is greater than a preset threshold; when the number of attribute types to be calculated is greater than the preset threshold, performing the step of: obtaining the first centroid coordinates of the first vertex relative to the initial primitive in the image frame and the first perspective correction coefficient.
[0008] In the implementation of the above scheme, the adaptive adjustment of the sampling point attribute value calculation scheme is achieved by the number of attribute types to be calculated and the preset threshold, which helps to further reduce the computational load of the sampling point attribute value calculation scheme and thus improve the computational efficiency of the above image processing method.
[0009] In one implementation of the first aspect, the method further includes: when the number of attribute types to be calculated is not greater than the preset threshold, performing the following steps: obtaining the first centroid coordinates, third attribute information, and third perspective correction coefficient of the first vertex relative to the initial primitive; performing perspective correction on the third attribute information using the third perspective correction coefficient; obtaining the third centroid coordinates and fourth perspective correction coefficient of the sampling point relative to the second primitive; obtaining the second attribute information of the sampling point based on the third centroid coordinates and the perspective-corrected third attribute information; performing perspective correction on the second attribute information using the fourth perspective correction coefficient; and rendering the sampling point based on the perspective-corrected second attribute information.
[0010] In the implementation of the above scheme, when the number of attribute types to be calculated is not greater than a preset threshold, the attribute values of the sampling points in the screen space are obtained by directly calculating the new vertex attribute values in the clipping space. This enables adaptive selection of the sampling point attribute value calculation scheme, which helps to further reduce the computational amount of the sampling point attribute value calculation scheme and thus improve the computational efficiency of the above image processing method.
[0011] In one implementation of the first aspect, obtaining the third attribute information includes: for the new primitive generated after the cropping process, performing three-dimensional linear interpolation based on the first attribute information of the initial primitive and the first centroid coordinates to obtain the third attribute information of the new primitive.
[0012] In the implementation of the above scheme, three-dimensional linear interpolation based directly on the first attribute information and first centroid coordinates of the initial primitive can quickly obtain the third attribute information of the new primitive in the clipping space, which is beneficial to improving the computational efficiency of the above image processing method.
[0013] In one implementation of the first aspect, obtaining the second attribute information of the sampling point based on the third centroid coordinates and the third attribute information after perspective correction includes: performing two-dimensional linear interpolation based on the third centroid coordinates and the third attribute information after perspective correction to obtain the second attribute information of the sampling point.
[0014] In the implementation of the above scheme, two-dimensional linear interpolation is performed directly based on the third centroid coordinates and the third attribute information after perspective correction to obtain the second attribute information of the sampling point. This can quickly obtain the attribute values of the sampling point in the screen space, which is beneficial to improving the computational efficiency of the above image processing method.
[0015] In one implementation of the first aspect, obtaining the first centroid coordinates includes: for the new vertex generated after the clipping process, performing three-dimensional linear interpolation based on the clipping position of the new vertex and the centroid coordinates of the initial vertex to obtain the centroid coordinates of the new vertex relative to the initial primitive.
[0016] In the implementation of the above scheme, for the new vertex generated after the clipping process, the centroid coordinates of the new vertex relative to the initial primitive can be obtained by performing three-dimensional linear interpolation based on the clipping position of the new vertex and the centroid coordinates of the initial vertex. On the one hand, the first centroid coordinates can be obtained more quickly through three-dimensional linear interpolation, which is beneficial to improving the computational efficiency of the above image processing method. On the other hand, the interpolation scheme can be applied to various forms of primitives, thereby making the above image processing method applicable to more application scenarios and improving the adaptability of the above image processing method.
[0017] In one implementation of the first aspect, obtaining the fourth centroid coordinates of the sampling point relative to the initial primitive based on the second centroid coordinates and the third centroid coordinates includes: performing two-dimensional linear interpolation based on the second centroid coordinates and the third centroid coordinates to obtain the fourth centroid coordinates of the sampling point relative to the initial primitive.
[0018] In the implementation of the above scheme, the fourth centroid coordinates of the sampling point in the screen space relative to the initial primitive in the clipping space can be obtained by two-dimensional linear interpolation. Then, the attribute value of the sampling point can be determined by the fourth centroid coordinates and the first attribute information of the initial primitive. Compared with the scheme of directly interpolating the attribute value in related technologies, the above scheme simplifies the calculation process and is conducive to improving the calculation efficiency of the above image processing method.
[0019] In one implementation of the first aspect, obtaining the second attribute information of the sampling point based on the fourth centroid coordinates after perspective correction and the first attribute information includes: performing two-dimensional linear interpolation based on the fourth centroid coordinates after perspective correction and the first attribute information to obtain the second attribute information of the sampling point.
[0020] In the implementation of the above scheme, the second attribute information of the sampling points can be directly obtained by two-dimensional linear interpolation using the fourth centroid coordinates and the first attribute information, which are all located in the clipping space. This simplifies the attribute value calculation process and helps to improve the computational efficiency of the above image processing method.
[0021] In one implementation of the first aspect, the three-dimensional linear interpolation includes: three-dimensional linear interpolation of the centroid coordinates, and / or, three-dimensional linear interpolation of the plane equation.
[0022] In the implementation of the above scheme, three-dimensional linear interpolation can be selected from at least one of three-dimensional linear interpolation of barycentric coordinates and three-dimensional linear interpolation of plane equations, so that the above image processing method can be applied to more application scenarios, which is conducive to improving the flexibility and adaptability of the above image processing method.
[0023] In one implementation of the first aspect, the two-dimensional linear interpolation includes: two-dimensional linear interpolation of the barycentric coordinates, and / or, two-dimensional linear interpolation of the plane equation.
[0024] In the implementation of the above scheme, two-dimensional linear interpolation can be selected from at least one of two-dimensional linear interpolation of barycentric coordinates and two-dimensional linear interpolation of plane equations, so that the above image processing method can be applied to more application scenarios, which is conducive to improving the flexibility and adaptability of the above image processing method.
[0025] In one implementation of the first aspect, the method further includes: storing the attribute information of reusable vertices in the same storage address; wherein the reusable vertices are used to represent the same vertex between target primitives; the target primitives are primitives that are in the same space and have at least one overlapping vertex.
[0026] In the implementation of the above scheme, by storing the attribute information of reusable vertices in the same storage address, on the one hand, the amount of repeated calculations for the same vertex can be reduced, which is beneficial to improving the computational efficiency of the above image processing method; on the other hand, storage address space can be saved, which is beneficial to reducing the area requirements of the above image processing method on hardware.
[0027] Secondly, embodiments of this application provide an image processor, comprising:
[0028] The first acquisition module is used to acquire the first centroid coordinates of the first vertex relative to the initial primitive in the image frame and the first perspective correction coefficient; wherein, the first vertex is the vertex of the first primitive in the clipping space, the first primitive includes a new primitive generated after clipping the initial primitive, and / or the initial primitive without the clipping process; the initial vertex is the vertex of the initial primitive;
[0029] The first perspective correction module is used to perform perspective correction on the first centroid coordinates using the first perspective correction coefficient.
[0030] The second acquisition module is used to convert the first centroid coordinates after perspective correction to screen space and acquire the second centroid coordinates of the second vertex relative to the initial primitive; wherein, the second vertex is the vertex of the second primitive, and the second primitive is acquired by converting the first primitive to the screen space;
[0031] The third acquisition module is used to acquire the third centroid coordinates of the sampling point relative to the second graphic element; wherein, the sampling point is a sampling point in the second graphic element;
[0032] The fourth acquisition module is used to acquire the fourth centroid coordinates of the sampling point relative to the initial primitive and the second perspective correction coefficient based on the second centroid coordinates and the third centroid coordinates;
[0033] The second perspective correction module is used to perform perspective correction on the fourth centroid coordinates using the second perspective correction coefficient.
[0034] The fifth acquisition module is used to acquire the second attribute information of the sampling point based on the fourth centroid coordinates after perspective correction and the first attribute information; wherein, the first attribute information is the attribute information of the initial vertex;
[0035] The first rendering module is used to render the sampling points based on the second attribute information.
[0036] Thirdly, embodiments of this application provide an electronic device, including: an image processor, wherein the image processor is provided in the second aspect or any possible implementation thereof.
[0037] Fourthly, embodiments of this application provide a computer-readable storage medium storing computer program instructions, which, when read and executed by a processor, perform the method provided in the first aspect or any possible implementation thereof.
[0038] Fifthly, embodiments of this application provide a computer program product, the computer program product including a computer program, which, when executed by a processor, implements the method provided by the first aspect or any possible implementation of the first aspect.
[0039] Other features and advantages of this application will be set forth in the following description and will be apparent in part from the description or may be learned by practicing embodiments of this application. The objectives and other advantages of this application may be realized and obtained by means of the structures particularly pointed out in the written description, claims, and drawings. Attached Figure Description
[0040] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0041] Figure 1 is a flowchart illustrating the sampling point attribute value acquisition scheme in related technologies;
[0042] Figure 2 is a schematic flowchart of the image processing method provided in the embodiments of this application;
[0043] Figure 3 is a schematic diagram of a triangle primitive after a cropping operation in a certain scenario provided in an embodiment of this application;
[0044] Figure 4 is a schematic diagram illustrating the physical meaning of the centroid coordinates of any point inside the triangular primitive provided in the embodiments of this application;
[0045] Figure 5 is a schematic diagram of the new graphic elements generated after a cropping operation in a certain scenario provided in an embodiment of this application;
[0046] Figure 6 is another flowchart illustrating the image processing method provided in an embodiment of this application;
[0047] Figure 7 is a schematic diagram of the structure of the image processor provided in an embodiment of this application. Detailed Implementation
[0048] The technical solutions of the embodiments of this application will be described below with reference to the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solutions of this application, and are therefore merely examples and should not be used to limit the scope of protection of this application.
[0049] This application provides an image processing method based on the invariance of the property that the sum of the barycentric coordinates (BC) components is one. For a cropped primitive, instead of directly calculating the attribute values of the new vertices in the crop space, this method calculates the barycentric coordinates of the new vertices relative to the initial primitive. In screen space, based on these barycentric coordinates, the barycentric coordinates of the sampling point relative to the initial primitive are obtained. Finally, the attribute values of the sampling point are obtained based on the attribute values of the initial primitive vertices and the barycentric coordinates of the sampling point relative to the initial primitive. On the one hand, this scheme reduces the number of linear interpolations, improving computational efficiency. On the other hand, compared with related technologies, this scheme simplifies the calculation process, avoiding frequent conversions and repetitive calculations between the crop space and screen space, further improving computational efficiency.
[0050] The image processing method described above will be described in detail below. Referring to Figure 2, an embodiment of this application provides an image processing method, which includes:
[0051] Step S110: Obtain the first centroid coordinates of the first vertex relative to the initial primitive in the image frame and the first perspective correction coefficient; wherein, the first vertex is the vertex of the first primitive in the clipping space, the first primitive includes the new primitive generated after clipping the initial primitive, and / or, the initial primitive without clipping; the initial vertex is the vertex of the initial primitive;
[0052] Step S120: Perform perspective correction on the first centroid coordinates using the first perspective correction coefficient;
[0053] Step S130: Transform the first centroid coordinates after perspective correction to screen space, and obtain the second centroid coordinates of the second vertex relative to the initial primitive; wherein, the second vertex is the vertex of the second primitive, and the second primitive is obtained by transforming the first primitive to screen space;
[0054] Step S140: Obtain the third centroid coordinates of the sampling point relative to the second primitive; where the sampling point is a sampling point in the second primitive;
[0055] Step S150: Based on the second and third centroid coordinates, obtain the fourth centroid coordinates of the sampling point relative to the initial primitive and the second perspective correction coefficient;
[0056] Step S160: Perform perspective correction on the fourth centroid coordinates using the second perspective correction coefficient;
[0057] Step S170: Based on the fourth centroid coordinates and the first attribute information after perspective correction, obtain the second attribute information of the sampling point; wherein, the first attribute information is the attribute information of the initial vertex;
[0058] Step S180: Render the sampling points based on the second attribute information.
[0059] The space corresponding to the centroid coordinates involved in steps S110 to S180 above will be described as follows:
[0060] The centroid coordinates relative to the clipping space include: the first centroid coordinate, the second centroid coordinate, and the fourth centroid coordinate;
[0061] The centroid coordinates relative to screen space include: the third centroid coordinates.
[0062] The following section introduces the application of the above image processing methods in the image rendering process:
[0063] The image rendering process generally includes:
[0064] (1) Vertex processing, mainly including:
[0065] Determine the primitive vertices, which contain the vertex's position information in three-dimensional space (e.g., (x, y, z) coordinates) and other possible attribute information, such as color, texture, etc.
[0066] Transform the vertices of primitives, including model transformation, view transformation, projection transformation, etc., to convert the vertices of primitives from model space to clip space.
[0067] (2) Clip Operation, which mainly includes:
[0068] In the clipping space, it is determined whether the primitive is completely inside the view frustum. If the primitive is partially or completely outside the view frustum, a clipping operation is required.
[0069] The clipping operation generates new vertices that lie on the boundary of the view frustum and together with the vertices of the initial primitive located within the view frustum, form a new primitive.
[0070] (3) Coordinate transformation, mainly including:
[0071] Transform the vertex coordinates of primitives in clip space to screen space to prepare for the subsequent rasterization process;
[0072] (4) Rasterization, mainly including:
[0073] In screen space, primitives are converted into a series of sampling points, which will be used for image rendering;
[0074] The rasterization process involves determining which sampling points are located inside the triangle and calculating the attribute values of these sampling points.
[0075] (5) Coloring, mainly including:
[0076] Based on the obtained sampling point attribute values, the sampling points are colored.
[0077] (6) Synthesis, mainly including:
[0078] The colored sample points are composited into the final image, which typically involves merging the currently rendered primitives with other already rendered primitives or the background.
[0079] Steps S110 to S180 in the above image processing method are applied to the process after the cropping operation in the above rendering scheme. The first vertex in step S110 refers to the primitive vertex after the above cropping operation. The process of transforming the first centroid coordinates to screen space in step S130 is the above coordinate transformation process. The sampling point in step S140 is the sampling point determined in the above rasterization process. The sampling point attribute value calculation steps involved in steps S140 to S170 are the above rasterization steps. The process of rendering the sampling points based on the second attribute information in step S180 can include the above shading steps and compositing steps.
[0080] The following proves the invariance of the property that the sum of the barycentric coordinate components is the same during the transformation from clip space to screen space involved in the above scheme. Specifically, it proves that the fourth barycentric coordinate of the sampling point obtained using the above image processing method relative to the initial primitive is equivalent to the barycentric coordinate of the corresponding point in clip space relative to the initial primitive. Taking a triangle primitive as an example, see Figure 3. The vertices of the initial triangle are V0, V1, and V2. After the clipping operation, the vertices of the resulting triangle are V3, V4, and V5. The sampling point for calculating the attribute value is V6. It can be understood that V6 should be the sampling point of the triangle primitive in screen space. The V6 shown in Figure 3 is the point in clip space corresponding to the sampling point V6. The variable subscript represents a vertex, the superscript represents the corresponding space or triangle, clip represents the clipping space or the initial triangle, and screen represents the clipped triangle primitive or screen space. The proof process is as follows:
[0081] Please refer to Figure 4. For a triangle with vertices V0, V1, and V2, the barycentric coordinates (i, j, k) represent the position of a point within the triangle primitive relative to the three vertices of the triangle primitive. The components i, j, and k of the barycentric coordinates are the BC (Barycentric Coordinates) values of the point (x, y) within the triangle primitive relative to vertices V0, V1, and V2, respectively. The physical meaning of the barycentric coordinates of a point (x, y) within the triangle primitive is the ratio of the area of the triangle formed by the point (x, y) and the opposite side of a vertex to the area of the original triangle, that is:
[0082] For a point (x) in clip space clip ,y clip ,z clip ), its components relative to the centroid coordinates of the vertices of the clipping space primitive. and satisfy:
[0083] For a point (x) in screen space sceen ,y sceen), its components relative to the barycentric coordinates of the screen space primitive vertices. and satisfy:
[0084] Let w be the perspective correction factor for a point inside the triangle. The perspective correction factor is mainly used to correct perspective distortion caused by perspective projection. Then, what are the barycentric coordinate components in screen space? and With the centroid coordinate components in clipping space and The relationship is:
[0085] If we need to prove that although the coordinates change under perspective transformation, the property that the sum of the barycentric coordinate components is one remains unchanged, then we need to prove:
[0086] The above and Substituting the above We can obtain:
[0087] Combine like terms:
[0088] because:
[0089] We can conclude that:
[0090] So:
[0091] Therefore, it has been proven that:
[0092] In summary, we can conclude that:
[0093] Although the coordinates change under perspective transformation, the property that the sum of the barycentric coordinate components is one remains unchanged.
[0094] Before introducing the optional implementation methods of steps S110 to S180 above, let's take the triangular primitive shown in Figure 4 as an example to introduce the principle of obtaining attribute values involved in the embodiments of this application:
[0095] The attribute value of a sampling point within a triangle can be obtained using the following linear interpolation method: Attr (x0,y0) =Attr V0 ·i+Attr V1 ·j+Attr V2 ·k
[0096] Among them, Attr(x0,y0) Here, (x0, y0) represents the attribute value of point (x0, y0); (i, j, k) represents the centroid coordinates of point (x0, y0) relative to the triangle primitive with vertices V0, V1, and V2. In the above interpolation scheme, i, j, and k can be referred to as the centroid coordinate coefficients; Attr V0 Attr V1 and Attr V2 These are the attribute values for vertices V0, V1, and V2, respectively.
[0097] The optional implementation methods of steps S110 to S180 described above are described below:
[0098] It is understood that the first vertex in step S110 is the vertex of the first primitive in the clipping space, and the first primitive includes at least one of the following:
[0099] (1) New primitives generated after trimming the initial primitives;
[0100] Please refer to Figure 5. Taking a triangle as an initial primitive in a scene as an example, the three vertices of the initial primitive are V0', V1' and V2'. After clipping, the new vertices generated are V3' and V4'. The new primitives generated after clipping include, for example, triangle primitives composed of vertices V0', V3' and V4', as well as triangle primitives composed of vertices V0', V2' and V4'.
[0101] (2) Initial primitives that have not been clipped.
[0102] It is understood that the new primitives generated by the clipping process and the initial primitives that have not been clipped, which are included in the first primitive mentioned above, do not refer to the two processing states of the same primitive before and after the clipping process. Rather, they refer to the new primitives generated by the clipping operation and the initial primitives that have not been clipped among all primitives after the clipping operation.
[0103] The following describes the method for obtaining the coordinates of the first centroid in step S110 above:
[0104] As an optional implementation of the above image processing method, step S110, which obtains the first centroid coordinates, includes:
[0105] For the new vertices generated after the clipping process, the centroid coordinates of the new vertex relative to the initial primitive are obtained based on the clipping position of the new vertex and the centroid coordinates of the initial vertex. An example of this implementation is:
[0106] It is understood that the first centroid coordinates of the first vertex relative to the initial primitive include: the centroid coordinates of the new vertex generated after clipping relative to the initial primitive, and / or the centroid coordinates of the initial vertex without clipping relative to the initial primitive.
[0107] During the clipping operation, the clipping interface equation can be determined. Based on the clipping interface equation and the initial vertex positions of the initial primitives, the clipping position of the new vertex can be determined. Then, based on the clipping position and the centroid coordinates of the initial vertex, three-dimensional linear interpolation is performed. Taking the new vertex V3' in the scene shown in Figure 5 as an example, the new vertex V3' is the intersection of the edge V0'V1' of the initial triangle and the clipping interface. The new vertex V3' is located on the line segment V0'V1'. The position of the new vertex V3' can be parametrically represented as: V3'=tV0'+(1-t)V1',0≤t≤1
[0108] Once the parameter t is determined based on the clipping position of the new vertex V3', it can be determined by three-dimensional linear interpolation.
[0109] In addition, it is understandable that, besides using interpolation, the bary coordinates of the new vertex relative to the initial primitive can also be calculated directly based on the clipping position of the new vertex according to the physical definition of the bary coordinates mentioned above.
[0110] Additionally, it is understandable that the initial vertices of untrimmed primitives can be directly obtained without the need for 3D linear interpolation.
[0111] The above scheme addresses the new vertices generated after cropping. By performing three-dimensional linear interpolation based on the cropping position of the new vertex and the centroid coordinates of the initial vertex, the centroid coordinates of the new vertex relative to the initial primitive can be obtained. On the one hand, three-dimensional linear interpolation can obtain the first centroid coordinates more quickly, which is beneficial to improving the computational efficiency of the above image processing method. On the other hand, the interpolation scheme can be applied to various types of primitives, thus making the above image processing method applicable to more application scenarios and improving its adaptability.
[0112] It is understandable that the above step S110 can also obtain the first perspective correction coefficient of the new vertex generated by the clipping process through a three-dimensional linear interpolation method.
[0113] The following describes the fluoroscopic correction scheme for step S120 above:
[0114] In computer graphics, perspective projection is a common projection method used to simulate how the human eye perceives objects, making distant objects appear smaller and closer objects appear larger. This perspective effect is particularly important when rendering 3D scenes, as it enhances the realism and three-dimensionality of the scene. However, during rasterization, if interpolation or texture mapping is directly applied to the transformed vertices without perspective correction, the perspective effect will be lost. This is because points within the graphic are not involved in the transformation calculation and therefore cannot accurately represent the perspective effect. Therefore, perspective correction can be used to correct the perspective of the barycentric coordinates, thus preserving the perspective effect of the primitive vertices.
[0115] For example, perspective correction coefficients are typically obtained through the depth values of vertices to ensure that the attribute values of the sampled points obtained in screen space are consistent with the attribute values in the actual 3D space.
[0116] For the scheme of transforming the barycentric coordinates to screen space in step S130 above, please refer to the components of the barycentric coordinates in screen space in the aforementioned proof process. and The relationship between the centroid coordinates and the clipping space is not elaborated here.
[0117] It should be noted that the second centroid coordinates obtained by converting the first centroid coordinates to screen space in step S130 are the centroid coordinates of the second vertex relative to the initial primitive in clipping space, and not the centroid coordinates of the second primitive relative to screen space.
[0118] The following describes the method for obtaining the third centroid coordinates of the sampling point relative to the second primitive in step S140:
[0119] For example, after rasterizing the primitives, the specific location of the sampling point can be determined. Based on the specific location of the sampling point and the physical definition of the centroid coordinates mentioned above, the third centroid coordinates of the sampling point relative to the second primitive can be calculated.
[0120] The following describes the method for obtaining the fourth centroid coordinates of the sampling point relative to the initial primitive in step S150:
[0121] As an optional implementation of the above image processing method, step S150, which obtains the fourth centroid coordinates of the sampling point relative to the initial primitive based on the second and third centroid coordinates, includes: performing two-dimensional linear interpolation based on the second and third centroid coordinates to obtain the fourth centroid coordinates of the sampling point relative to the initial primitive.
[0122] It is understandable that the second centroid coordinates mentioned above are the centroid coordinates of the second vertex of the second primitive in screen space relative to the initial primitive in clipping space, and the third centroid coordinates are the centroid coordinates of the sampling point within the second primitive in screen space relative to the second primitive. If the second centroid coordinates of the second vertex of the second primitive relative to the initial primitive are used as the attribute value in the above attribute interpolation scheme, and the third centroid coordinates of the sampling point relative to the second primitive are determined as the centroid coordinate coefficients, then the fourth centroid coordinates of the sampling point relative to the initial primitive can be obtained by two-dimensional linear interpolation.
[0123] The above scheme can obtain the fourth centroid coordinates of the sampling point in the screen space relative to the initial primitive in the clipping space through two-dimensional linear interpolation. Then, the attribute value of the sampling point can be determined by the fourth centroid coordinates and the first attribute information of the initial primitive. Compared with the scheme of directly interpolating the attribute value in related technologies, the above scheme simplifies the calculation process and helps to improve the calculation efficiency of the above image processing method.
[0124] It is understood that the scheme for obtaining the second perspective correction coefficient in step S150 is similar to the scheme for obtaining the fourth centroid coordinates, and will not be described again in this embodiment. The scheme for performing perspective correction on the fourth centroid coordinates using the second perspective correction coefficient in step S160 is similar to the scheme for performing perspective correction on the first centroid coordinates using the first perspective correction coefficient mentioned above. For the specific implementation method, please refer to the aforementioned content, and will not be described again here.
[0125] The following describes the scheme for obtaining the second attribute information in step S170 above:
[0126] As an optional implementation of the above image processing method, step S170, based on the fourth centroid coordinates after perspective correction and the first attribute information, obtains the second attribute information of the sampling point, including: performing two-dimensional linear interpolation based on the fourth centroid coordinates after perspective correction and the first attribute information to obtain the second attribute information of the sampling point.
[0127] The above scheme can directly obtain the second attribute information of the sampling point through two-dimensional linear interpolation by using the fourth centroid coordinates and the first attribute information, which are both in the clipping space. This simplifies the attribute value calculation process and helps to improve the computational efficiency of the above image processing method.
[0128] It is understood that the implementation method of rendering the sampling points using the second attribute information in step S180 above can refer to related technologies, and will be described in detail in the embodiments of this application.
[0129] It is understandable that the above-mentioned scheme for interpolating attribute values by utilizing the property that the sum of the barycentric coordinate components is one can still be simplified in certain scenarios, such as when the number of attribute types to be calculated is small. Based on this, the embodiments of this application provide the following scheme:
[0130] As an optional implementation of the above image processing method, the above image processing method further includes: determining whether the number of attribute types to be calculated is greater than a preset threshold; when the number of attribute types to be calculated is greater than the preset threshold, performing the above steps S110 to S180.
[0131] It is understandable that the above image processing method can adaptively select a specific sampling point attribute value acquisition method based on a preset threshold. When the number of attribute types to be calculated is greater than the preset threshold, the sampling point attribute value acquisition scheme shown in steps S110 to S180 above is selected. When the number of attribute types to be calculated is not greater than the preset threshold, a sampling point attribute value calculation scheme with less computation can be selected, thereby achieving adaptive adjustment of the sampling point attribute value calculation scheme based on the number of attribute types to be calculated.
[0132] The above scheme adaptively adjusts the calculation scheme of the sampling point attribute values by adjusting the number of attribute types to be calculated and the preset threshold, which helps to further reduce the computational load of the sampling point attribute value calculation scheme and thus improve the computational efficiency of the above image processing method.
[0133] The following describes the attribute value calculation schemes that can be used when the number of attribute types to be calculated is no greater than a preset threshold:
[0134] Please refer to Figure 6. As an optional implementation of the above image processing method, when the number of attribute types to be calculated is not greater than a preset threshold, the following steps are performed:
[0135] Step S210: Obtain the first centroid coordinates, third attribute information, and third perspective correction coefficient of the first vertex relative to the initial primitive;
[0136] Step S220: Perform perspective correction on the third attribute information using the third perspective correction coefficient;
[0137] Step S230: Obtain the third centroid coordinates and the fourth perspective correction coefficient of the sampling point relative to the second primitive;
[0138] Step S240: Based on the third centroid coordinates and the third attribute information after perspective correction, obtain the second attribute information of the sampling point;
[0139] Step S250: Perform perspective correction on the second attribute information using the fourth perspective correction coefficient;
[0140] Step S260: Render the sampling points based on the second attribute information after perspective correction.
[0141] The space corresponding to the centroid coordinates involved in steps S210 to S260 above is described below:
[0142] The centroid coordinates for the clipping space include: the first centroid coordinate;
[0143] The centroid coordinates for screen space include: the third centroid coordinates.
[0144] The following describes the method for determining the aforementioned preset threshold in a specific scenario:
[0145] Assuming the number of initial triangular primitives to be processed is n, the number of attribute types to be calculated at the vertices of the triangular primitives is m, the number of sampling points within the triangular primitives is s, the proportion of primitives to be clipped from all initial triangular primitives is a, and the number of linear interpolations required is L, for the sampling point attribute value calculation scheme shown in steps S110 to S180 above, the number of linear interpolations required in the clipping space is: L clip =n clip ·2·a
[0146] Where, n clip The number of initial triangular primitives in the clipping space;
[0147] The number of linear interpolations required in screen space is: L screen =n screen ·2·a
[0148] Where, n screen The number of triangular primitives in screen space;
[0149] For the sampling point attribute value calculation scheme shown in steps S210 to S260 above, the number of linear interpolations required in the clipping space is: L clip ′=n clip ·m·a
[0150] The number of linear interpolations required in screen space is: n L screen ′=n scre □·m·s
[0151] Understandably, besides linear interpolation, the computational cost of each triangular primitive includes (1+2m) additions and 3m multiplications. To make the comparison of computational costs more intuitive, the linear interpolation in clipping space is simplified to linear interpolation in screen space. Since screen space interpolation can be performed using planar equation interpolation, the number of additions and multiplications required for the sampling point attribute value calculation scheme shown in steps S110 to S180 are respectively: Add1 = n clip ·(17+6a)+n screen ·(18+6s+2m) Multi1=n clip ·(14+4a)+n screen (14+4s+3m)
[0152] The number of additions and multiplications required for the sampling point attribute value calculation scheme shown in steps S210 to S260 above are respectively: Add2 = n clip ·(5+2a+6m+2am)+n screen ·(5+2s+6m+2sm) Multi2=n clip ·(2+6m+2am)+n screen ·(2+6m+2sm)
[0153] Calculations show that when the number of attribute types to be calculated for the triangular primitive is greater than or equal to 3 and 4 respectively, the computational complexity of the sampling point attribute value calculation scheme shown in steps S110 to S180 is better than that of the sampling point attribute value calculation scheme shown in steps S210 to S260. Therefore, the preset threshold can be set to 3 or 4.
[0154] It is understandable that the above-mentioned scheme of adaptively selecting the sample point attribute value calculation by the number of types of attributes to be calculated and the preset threshold can be controlled by software at the top level (the highest level of software architecture) through register configuration and combined with hardware to achieve adaptive interpolation scheme selection.
[0155] The above scheme obtains the attribute values of the sampling points in the screen space by directly calculating the new vertex attribute values in the clipping space when the number of attribute types to be calculated is no greater than a preset threshold. This enables adaptive selection of the sampling point attribute value calculation scheme, which helps to further reduce the computational amount of the sampling point attribute value calculation scheme and thus improves the computational efficiency of the above image processing method.
[0156] The following describes the part of the sampling point attribute value calculation scheme shown in steps S210 to S260 that differs from the sampling point attribute value calculation scheme shown in steps S110 to S180:
[0157] As an optional implementation of the above image processing method, step S210 of obtaining the third attribute information includes: for the new primitive generated after cropping, performing three-dimensional linear interpolation based on the first attribute information of the initial primitive and the first centroid coordinates to obtain the third attribute information of the new primitive.
[0158] It is understandable that both the initial primitive and the new primitive generated after clipping are in clipping space, and the first centroid coordinates of the first vertex are also relative to the initial primitive in clipping space. Therefore, the third attribute information of the new vertex can be directly interpolated based on the first attribute information of the initial vertex in the initial primitive and the centroid coordinates of the new vertex generated after clipping.
[0159] The above scheme directly performs three-dimensional linear interpolation based on the first attribute information and first centroid coordinates of the initial primitives, which can quickly obtain the third attribute information of the new primitives in the clipping space, thus improving the computational efficiency of the above image processing method.
[0160] As an optional implementation of the above image processing method, step S240, based on the third centroid coordinates and the third attribute information after perspective correction, obtains the second attribute information of the sampling point, including: performing two-dimensional linear interpolation based on the third centroid coordinates and the third attribute information after perspective correction to obtain the second attribute information of the sampling point.
[0161] It is understandable that the aforementioned third centroid coordinates are the centroid coordinates of the sampling point relative to the second primitive in screen space, and the third attribute information is the vertex attribute information of the first primitive after cropping. Therefore, the second attribute information of the sampling point can be obtained directly by performing two-dimensional linear interpolation based on the third centroid coordinates and the third attribute information after perspective correction.
[0162] The above scheme directly uses two-dimensional linear interpolation based on the third centroid coordinates and the third attribute information after perspective correction to obtain the second attribute information of the sampling points. This can quickly obtain the attribute values of the sampling points in the screen space, which is beneficial to improving the computational efficiency of the above image processing method.
[0163] The following section uses a triangular primitive as an example to introduce the optional implementation methods of the linear interpolation scheme in the two sampling point attribute value calculation schemes mentioned above:
[0164] It is understandable that for any triangle in two-dimensional space, the attribute value A of any point (x, y) inside it can be obtained by linear interpolation of the barycentric coordinates: A = ([(x2-x1)(y-y1)-(x-x1)(y2-y1)]·a0 + [(x0-x2)(y-y2)-(x-x2)(y0-y2)]·a1 + [(x1-x0)(y-y0)-(x-x0)(y1-y0)]·a2) / 2Area
[0165] Where (x1,y1), (x2,y2) and (x3,y3) are the coordinates of the three vertices of the triangle; a0, a1 and a2 are the attribute values of the three vertices of the triangle; and Area is the area of the triangle.
[0166] Let Δy = y - y0, Δx = x - x0, then the above formula can be expressed as: A = (Δy[(a1-a0)(x0-x2)+(a2-a0)(x1-x0)] -Δx[(a1-a0)(y0-y2)+(a2-a0)(y1-y2)]+a0[(x2-x1)(y0-y1)-(x0-x1)(y2-y1)]) / 2Area
[0167] The above formula can be converted to: Attr (x,y) =Attr (x0,y0) +(dAttr / dx)*(x-x0)+(dAttr / dy)*(y-y0)
[0168] Where dAttr / dx and dAttr / dy represent the slopes of the attribute relative to the x and y directions, respectively.
[0169] The above formula is the linear interpolation scheme for the plane equation. Since the linear interpolation of the barycenter coordinates is consistent with the linear interpolation of the plane equation, the linear interpolation of the barycenter coordinates, the linear interpolation of the vertex attribute values, and the linear interpolation of the perspective correction coefficient in the embodiments of this application can be either linear interpolation of the plane equation or linear interpolation of the barycenter coordinates.
[0170] In addition, in practical applications, the linear interpolation method can be flexibly selected based on the PPA (representing performance, power, and area) effect to achieve the optimal PPA effect.
[0171] As an optional implementation of the above image processing method, the above three-dimensional linear interpolation includes:
[0172] Three-dimensional linear interpolation of the centroid coordinates, and / or three-dimensional linear interpolation of the plane equations.
[0173] As an optional implementation of the above image processing method, the above two-dimensional linear interpolation includes:
[0174] Two-dimensional linear interpolation of barycentric coordinates, and / or two-dimensional linear interpolation of plane equations.
[0175] Additionally, it is understandable that in some scenarios, the interpolation order between multiple sampling points within the same primitive is generally to calculate all attribute values of the current sampling point before switching to the next sampling point.
[0176] It is understandable that when performance is the primary consideration in the aforementioned related technologies for calculating the attribute values of sampling points, linear interpolation requires multiple and fixed calculations. To avoid blocking subsequent data and impacting performance, a significant amount of mathematical computation is needed, which substantially increases hardware area. Furthermore, since attribute value interpolation between multiple points has certain order requirements, some intermediate variables need to be retained until the attribute value interpolation of the entire triangle primitive is complete. When there are many types of attributes to be acquired, a larger cache area is required to store intermediate variables. When the drawing area is small, even more cache area is needed to process more primitives in the pipeline within rasterization. Based on this, the embodiments of this application provide the following solution:
[0177] As an optional implementation of the above image processing method, the image processing method further includes: storing the attribute information of reusable vertices in the same storage address; wherein, reusable vertices are used to represent the same vertex between target primitives; the target primitives are primitives that are in the same space and have at least one overlapping vertex.
[0178] Taking vertex V4' as shown in Figure 5 as an example, vertex V4' is shared by primitives V0'V3'V4' and V0'V4'V2'. In this case, V4' is a reusable vertex. The second attribute information of vertex V4' in screen space can be stored in the same memory address. When rendering other triangle primitives in screen space that use V4' as a vertex, the second attribute information of vertex V4' can be directly obtained from the memory address. When calculating the attribute values of sampling points, only non-reusable vertices need to be calculated, which improves image processing performance to some extent.
[0179] Understandably, in addition to the secondary attribute information of primitive vertices in screen space, other information about primitive vertices in screen space, such as barycentric coordinates, can also be stored in certain scenarios. Of course, information about primitive vertices in clip space can also be stored.
[0180] In addition, it is understandable that both of the above-mentioned sampling point attribute value calculation schemes can save the storage address space required for sampling point attribute value calculation by storing the attribute information of reusable vertices in the same storage address, thereby reducing the hardware area requirement.
[0181] In the implementation of the above scheme, by storing the attribute information of reusable vertices in the same storage address, on the one hand, the amount of repeated calculations for the same vertex can be reduced, which is beneficial to improving the computational efficiency of the above image processing method; on the other hand, storage address space can be saved, which is beneficial to reducing the area requirements of the above image processing method on hardware.
[0182] It should be noted that although the above description uses triangular primitives as the subject, this is not a specific limitation on the primitive type. In fact, planar equation interpolation schemes and barycentric coordinate interpolation schemes are not limited to triangles; any planar two-dimensional image has similar properties. That is, the primitives in the embodiments of this application can be various planar two-dimensional graphics.
[0183] In addition, it is understandable that, since the centroid coordinate components have the property that the sum is 1, taking a triangle primitive as an example, in the actual calculation process, only two components in the centroid coordinates can be used as the calculation objects. After calculating the BC values of the two components, the BC value of the third component can be obtained by subtracting it from 1. This can further reduce the amount of calculation of the sampling point attribute values, thereby further improving the calculation efficiency of the above image processing method.
[0184] Please refer to Figure 7. This application embodiment also provides an image processor 300, including:
[0185] The first acquisition module 310 is used to acquire the first centroid coordinates of the first vertex relative to the initial primitive in the image frame and the first perspective correction coefficient; wherein, the first vertex is the vertex of the first primitive in the clipping space, the first primitive includes a new primitive generated after clipping the initial primitive, and / or the initial primitive without the clipping process; the initial vertex is the vertex of the initial primitive;
[0186] The first perspective correction module 320 is used to perform perspective correction on the first centroid coordinates using the first perspective correction coefficient.
[0187] The second acquisition module 330 is used to convert the first centroid coordinates after perspective correction to screen space and acquire the second centroid coordinates of the second vertex relative to the initial primitive; wherein, the second vertex is the vertex of the second primitive, and the second primitive is acquired by converting the first primitive to the screen space;
[0188] The third acquisition module 340 is used to acquire the third centroid coordinates of the sampling point relative to the second graphic element; wherein, the sampling point is a sampling point in the second graphic element;
[0189] The fourth acquisition module 350 is used to acquire the fourth centroid coordinates of the sampling point relative to the initial primitive and the second perspective correction coefficient based on the second centroid coordinates and the third centroid coordinates;
[0190] The second perspective correction module 360 is used to perform perspective correction on the fourth centroid coordinates using the second perspective correction coefficient.
[0191] The fifth acquisition module 370 is used to acquire the second attribute information of the sampling point based on the fourth centroid coordinates after perspective correction and the first attribute information; wherein, the first attribute information is the attribute information of the initial vertex;
[0192] The first rendering module 380 is used to render the sampling points based on the second attribute information.
[0193] As an optional embodiment of the above-described image processor, the image processor further includes:
[0194] The adaptive selection module for calculation scheme is used to determine whether the number of attribute types to be calculated is greater than a preset threshold; when the number of attribute types to be calculated is greater than the preset threshold, the first acquisition module 310, the first perspective correction module 320, the second acquisition module 330, the third acquisition module 340, the fourth acquisition module 350, the second perspective correction module 360, the fifth acquisition module 370 and the first rendering module 380 are invoked.
[0195] As an optional embodiment of the above-described image processor, the image processor further includes:
[0196] The sixth acquisition module is used to acquire the first centroid coordinates, third attribute information and third perspective correction coefficient of the first vertex relative to the initial primitive;
[0197] The third perspective correction module is used to perform perspective correction on the third attribute information using the third perspective correction coefficient.
[0198] The seventh acquisition module is used to acquire the third centroid coordinates and the fourth perspective correction coefficient of the sampling point relative to the second primitive;
[0199] The eighth acquisition module is used to acquire the second attribute information of the sampling point based on the third centroid coordinates and the third attribute information after perspective correction;
[0200] The fourth perspective correction module is used to perform perspective correction on the second attribute information using the fourth perspective correction coefficient;
[0201] The second rendering module is used to render the sampling points based on the second attribute information after perspective correction;
[0202] The above-mentioned adaptive selection module for calculation scheme is used to determine whether the number of attribute types to be calculated is greater than a preset threshold; when the number of attribute types to be calculated is not greater than the preset threshold, the sixth acquisition module, the third perspective correction module, the seventh acquisition module, the eighth acquisition module, the fourth perspective correction module, and the second rendering module are called.
[0203] As an optional implementation of the above image processor, the sixth acquisition module is specifically used to: for the new primitive generated after the cropping process, perform three-dimensional linear interpolation based on the first attribute information of the initial primitive and the first centroid coordinates to obtain the third attribute information of the new primitive.
[0204] As an optional implementation of the above image processor, the eighth acquisition module is specifically used to: perform two-dimensional linear interpolation based on the third centroid coordinates and the third attribute information after perspective correction to obtain the second attribute information of the sampling point.
[0205] As an optional implementation of the above image processor, the sixth acquisition module is specifically used to: for the new vertex generated after the cropping process, perform three-dimensional linear interpolation based on the cropping position of the new vertex and the centroid coordinates of the initial vertex to obtain the centroid coordinates of the new vertex relative to the initial primitive.
[0206] As an optional implementation of the above-mentioned image processor, the fourth acquisition module 350 is specifically used to: perform two-dimensional linear interpolation based on the second centroid coordinates and the third centroid coordinates to obtain the fourth centroid coordinates of the sampling point relative to the initial primitive.
[0207] As an optional implementation of the above-mentioned image processor, the fifth acquisition module 370 is specifically used to: perform two-dimensional linear interpolation based on the fourth centroid coordinates after perspective correction and the first attribute information to acquire the second attribute information of the sampling point.
[0208] As an optional implementation of the aforementioned image processor, the three-dimensional linear interpolation includes: three-dimensional linear interpolation of the centroid coordinates, and / or, three-dimensional linear interpolation of the plane equation.
[0209] As an optional implementation of the aforementioned image processor, the two-dimensional linear interpolation includes: two-dimensional linear interpolation of the centroid coordinates, and / or, two-dimensional linear interpolation of the plane equation.
[0210] As an optional embodiment of the above-described image processor, the image processor further includes:
[0211] A reusable vertex storage module is used to store the attribute information of reusable vertices at the same storage address; wherein, the reusable vertex is used to represent the same vertex between target primitives; the target primitive is a primitive that is in the same space and has at least one overlapping vertex.
[0212] Based on the same inventive concept, embodiments of this application also provide an electronic device, including: an image processor, wherein the image processor is any of the above-described image processor 300.
[0213] It is understood that the number of image processors deployed in the aforementioned electronic devices can be one or more, and each can be an integrated circuit chip with signal processing capabilities. These processors can be data processing cores of GPUs (Graphics Processing Units), CPUs (Central Processing Units), AI (Artificial Intelligence), NPUs (Neural Network Processing Units), ISPs (Image Signal Processors), DPUs (Display Processing Units), VPUs (Video Processing Units), DSPs (Digital Signal Processors), etc., or processor chips applied to scenarios such as large-scale data computation. The above are merely examples and should not be construed as limiting this application.
[0214] This application also provides a computer-readable storage medium storing computer program instructions, which are read and executed by a computer processor to perform the image processing method provided in this application.
[0215] This application also provides a computer program product, which includes a computer program that, when executed, implements any of the above-described image processing methods.
[0216] The above description is merely an embodiment of this application and is not intended to limit the scope of protection of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application.
Claims
1. An image processing method, characterized in that, The method includes: Obtain the first centroid coordinates of the first vertex relative to the initial primitive in the image frame and the first perspective correction coefficient; wherein, the first vertex is the vertex of the first primitive in the clipping space, and the first primitive includes the new primitive generated after clipping the initial primitive, and / or the initial primitive without the clipping process; The first centroid coordinates are corrected using the first perspective correction coefficient. The first centroid coordinates after perspective correction are transformed to screen space to obtain the second centroid coordinates of the second vertex relative to the initial primitive; wherein, the second vertex is the vertex of the second primitive, and the second primitive is obtained by transforming the first primitive to the screen space; Obtain the third centroid coordinates of the sampling point relative to the second primitive; wherein, the sampling point is a sampling point in the second primitive; Based on the second and third centroid coordinates, the fourth centroid coordinates of the sampling point relative to the initial primitive and the second perspective correction coefficient are obtained. The fourth centroid coordinate is corrected using the second perspective correction coefficient. Based on the fourth centroid coordinates and the first attribute information after perspective correction, the second attribute information of the sampling point is obtained; wherein, the first attribute information is the attribute information of the initial vertex; the initial vertex is the vertex of the initial primitive; The sampling points are rendered based on the second attribute information.
2. The image processing method according to claim 1, characterized in that, The method further includes: Determine if the number of attribute types to be calculated exceeds a preset threshold; When the number of attribute types to be calculated is greater than the preset threshold, the following steps are performed: obtain the first centroid coordinates of the first vertex relative to the initial primitive in the image frame and the first perspective correction coefficient.
3. The image processing method according to claim 2, characterized in that, The method further includes: When the number of attribute types to be calculated is not greater than the preset threshold, the following steps are performed: Obtain the first centroid coordinates, third attribute information, and third perspective correction coefficient of the first vertex relative to the initial primitive; The third perspective correction coefficient is used to perform perspective correction on the third attribute information; Obtain the third centroid coordinates and the fourth perspective correction coefficient of the sampling point relative to the second primitive; Based on the third centroid coordinates and the third attribute information after perspective correction, the second attribute information of the sampling point is obtained; The second attribute information is corrected using the fourth perspective correction coefficient. The sampling points are rendered based on the second attribute information after perspective correction.
4. The image processing method according to claim 3, characterized in that, Obtaining the third attribute information includes: For the new primitives generated after the cropping process, three-dimensional linear interpolation is performed based on the first attribute information of the initial primitives and the first centroid coordinates to obtain the third attribute information of the new primitives.
5. The image processing method according to claim 3, characterized in that, The process of obtaining the second attribute information of the sampling point based on the third centroid coordinates and the third attribute information after perspective correction includes: Two-dimensional linear interpolation is performed based on the third centroid coordinates and the third attribute information after perspective correction to obtain the second attribute information of the sampling point.
6. The image processing method according to claim 3, characterized in that, Obtaining the coordinates of the first centroid includes: For the new vertex generated after the clipping process, a three-dimensional linear interpolation is performed based on the clipping position of the new vertex and the centroid coordinates of the initial vertex to obtain the centroid coordinates of the new vertex relative to the initial primitive.
7. The image processing method according to claim 1, characterized in that, The step of obtaining the fourth centroid coordinates of the sampling point relative to the initial primitive based on the second and third centroid coordinates includes: Two-dimensional linear interpolation is performed based on the second and third centroid coordinates to obtain the fourth centroid coordinates of the sampling point relative to the initial primitive.
8. The image processing method according to claim 1, characterized in that, The process of obtaining the second attribute information of the sampling point based on the fourth centroid coordinates after perspective correction and the first attribute information includes: Two-dimensional linear interpolation is performed based on the fourth centroid coordinates after perspective correction and the first attribute information to obtain the second attribute information of the sampling point.
9. The image processing method according to claim 4 or 6, characterized in that, The three-dimensional linear interpolation includes: Three-dimensional linear interpolation of the centroid coordinates, and / or three-dimensional linear interpolation of the plane equations.
10. The image processing method according to any one of claims 5, 7, and 8, characterized in that, The two-dimensional linear interpolation includes: Two-dimensional linear interpolation of barycentric coordinates, and / or two-dimensional linear interpolation of plane equations.
11. The image processing method according to any one of claims 1 to 8, characterized in that, The method further includes: The attribute information of reusable vertices is stored in the same storage address; wherein, the reusable vertices are used to represent the same vertex between target primitives; the target primitives are primitives that are in the same space and have at least one overlapping vertex.
12. An image processor, characterized in that, include: The first acquisition module is used to acquire the first centroid coordinates of the first vertex relative to the initial primitive in the image frame and the first perspective correction coefficient; wherein, the first vertex is the vertex of the first primitive in the clipping space, and the first primitive includes a new primitive generated after clipping the initial primitive, and / or the initial primitive without the clipping process; The first perspective correction module is used to perform perspective correction on the first centroid coordinates using the first perspective correction coefficient. The second acquisition module is used to convert the first centroid coordinates after perspective correction to screen space and acquire the second centroid coordinates of the second vertex relative to the initial primitive; wherein, the second vertex is the vertex of the second primitive, and the second primitive is acquired by converting the first primitive to the screen space; The third acquisition module is used to acquire the third centroid coordinates of the sampling point relative to the second graphic element; wherein, the sampling point is a sampling point in the second graphic element; The fourth acquisition module is used to acquire the fourth centroid coordinates of the sampling point relative to the initial primitive and the second perspective correction coefficient based on the second centroid coordinates and the third centroid coordinates; The second perspective correction module is used to perform perspective correction on the fourth centroid coordinates using the second perspective correction coefficient. The fifth acquisition module is used to acquire the second attribute information of the sampling point based on the fourth centroid coordinates after perspective correction and the first attribute information; wherein, the first attribute information is the attribute information of the initial vertex; the initial vertex is the vertex of the initial primitive; The first rendering module is used to render the sampling points based on the second attribute information.
13. An electronic device, characterized in that, include: Image processor; The image processor is the image processor according to claim 12.
14. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions, which, when executed by a computer, cause the computer to perform the method as described in any one of claims 1 to 11.
15. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the method as described in any one of claims 1 to 11.