Anisotropic filtering method and device
By determining the weight of the sampling point sequence and texture element group in anisotropic filtering, and performing weight accumulation and filtering calculations, the problem of performance degradation in traditional methods is solved, and efficient anisotropic filtering under lossless conditions is achieved.
Patent Information
- Application Number
- CN202210832108.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-15
- Publication Date
- 2025-01-21
- Estimated Expiration
- 2042-07-15
AI Technical Summary
While improving image clarity, traditional anisotropic filtering methods lead to significant performance declines, especially in high-level AF (such as AF16x), which requires 16 times the number of sampling points compared to bilinear filtering, which greatly affects the performance.
By determining the sampling point sequence of the pixel point on the texture map, and obtaining the weight of its corresponding texture element group for each sampling point, the weight is accumulated to obtain the total weight of each texture element, and then based on these total weights and color information Perform filtering calculations to avoid repeated texture element filtering calculations, thereby reducing the number of filtering calculations that really affect performance.
Optimizing anisotropic filtering performance under lossless conditions significantly improves image processing performance, especially in high-level AF situations, where the performance improvement can reach nearly 50%.
Smart Images

Figure CN117474798B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to an anisotropic filtering method and device. Background Art
[0002] In most cases, the coordinates of the texture map and the coordinates on the screen are not one-to-one corresponding, so in order to make the content displayed on the screen smoother, texture filtering technology is needed. The filtering modes include the following: Point (nearest point sampling), Bilinear (bilinear filtering), Trilinear (trilinear filtering) and Anisotropic Filtering (anisotropic filtering).
[0003] When the texture map is parallel to the screen, the quadrilateral formed by the four adjacent 2×2 pixels on the screen corresponding to the texture map must be a square, that is, isotropic. At this time, the bilinear filtering mode can be used, that is, the four texture elements (texel) around the texture coordinates are used to calculate a new color information as the value of the pixel according to the corresponding weight, so that the information displayed on the screen will be smoother. However, if the quadrilateral is not a square, it means that there is an angle of inclination between the texture map and the screen, that is, anisotropy. If bilinear filtering is used for anisotropy, the information in the distance will be blurred. At this time, anisotropic filtering (AF for short) is needed to make the texture of the inclined surface object clearer and sharper. Among them, anisotropic filtering will perform more bilinear filtering according to the angle formed by the texture map and the screen, so as to achieve better display effects.
[0004] Although anisotropic filtering has better clarity than bilinear filtering, it comes at the cost of a significant drop in performance. Traditional anisotropic filtering methods are mainly divided into: AF2x, AF4x, AF8x and AF16x. Among them, AF2x will split a pixel into two sampling points for bilinear filtering, while AF4x will split a pixel into 4 sampling points, AF8x will split a pixel into 8 sampling points, and AF16x will split a pixel into 16 sampling points. However, taking AF16x as an example, under the traditional anisotropic filtering method, the number of sampling points required for bilinear filtering is 16 times that of ordinary bilinear filtering, which greatly affects the performance. Summary of the invention
[0005] Based on this, in order to solve the above technical problems, an anisotropic filtering method and device are provided, which can optimize the anisotropic filtering performance under non-destructive conditions.
[0006] In a first aspect, the present application provides an anisotropic filtering method. The method comprises:
[0007] Determine a sampling point sequence corresponding to a pixel point on a texture map; wherein a distance between adjacent sampling points in the sampling point sequence is equal to a side length of a texture element in the texture map;
[0008] Determine a texture element group corresponding to each sampling point in the sampling point sequence on the texture map;
[0009] For each sampling point in the sampling point sequence, obtaining a weight of each texture element in the corresponding texture element group;
[0010] Based on the weight of each texture element in each texture element group, the weight corresponding to the same texture element is accumulated to obtain the total weight of each texture element;
[0011] Perform filtering calculation based on the total weight of each texture element and the color information of each texture element to obtain filtering calculation results corresponding to each texture element;
[0012] The color information of the pixel point is obtained according to the filtering calculation results corresponding to each texture element.
[0013] In a second aspect, the present application also provides an anisotropic filtering device. The device comprises:
[0014] A sampling point determination module, used to determine a sampling point sequence corresponding to a pixel point on a texture map; wherein the spacing between adjacent sampling points in the sampling point sequence is equal to the side length of a texture element in the texture map;
[0015] A texture element determination module, used to determine the texture element group corresponding to each sampling point in the sampling point sequence on the texture map;
[0016] A weight acquisition module, used for acquiring the weight of each texture element in the corresponding texture element group for each sampling point in the sampling point sequence;
[0017] A weight accumulation module, for accumulating the weight corresponding to the same texture element based on the weight of each texture element in each texture element group, to obtain a total weight of each texture element;
[0018] A filtering calculation module, used for performing filtering calculation based on the total weight of each texture element and the color information of each texture element, to obtain filtering calculation results corresponding to each texture element;
[0019] The result processing module is used to obtain the color information of the pixel point according to the filtering calculation results corresponding to each texture element.
[0020] The anisotropic filtering method and device described above determine a sampling point sequence corresponding to a pixel point on a texture map; the spacing between adjacent sampling points in the sampling point sequence is equal to the side length of a texture element in the texture map; determine a texture element group corresponding to each sampling point in the sampling point sequence on the texture map; obtain the weight of each texture element in the corresponding texture element group for each sampling point; based on the weight of each texture element in each texture element group, accumulate the weight corresponding to the same texture element to obtain the total weight of each texture element; perform filtering calculation based on the total weight of each texture element and the color information of each texture element to obtain the filtering calculation result corresponding to each texture element; and obtain the color information of the pixel point according to the filtering calculation result corresponding to each texture element. This scheme first merges the weights of the same texture elements to obtain the total weight of each texture element, and then performs filtering calculations based on the texture elements to obtain the color information of the pixels. It not only retains all information during the calculation process, that is, this is an information lossless method, but also avoids repeated filtering calculations on the same texture elements. The number of filtering calculations that really affect the performance is reduced compared to the traditional anisotropic filtering method, thereby improving the anisotropic filtering performance, thereby achieving the optimization of anisotropic filtering performance under lossless conditions. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 A schematic diagram of AF16x in an anisotropic example;
[0022] Figure 2 A schematic diagram of the process involved in the traditional anisotropic filtering method;
[0023] Figure 3 A schematic diagram of the relationship between adjacent sample points and their texture elements in an example;
[0024] Figure 4 is a schematic flow chart of an anisotropic filtering method in one embodiment;
[0025] Figure 5 is a flowchart of an anisotropic filtering method in an example;
[0026] Figure 6 A schematic diagram of a process of merging texture element weights in an example;
[0027] Figure 7 An auxiliary diagram for explaining performance optimization in an example;
[0028] Figure 8Another auxiliary diagram for explaining performance optimization in an example;
[0029] FIG9( a ) is an auxiliary diagram for illustrating performance optimization in another example;
[0030] FIG9( b ) is another auxiliary diagram for illustrating performance optimization in another example;
[0031] Fig.10 FIG. 4 is a structural block diagram of an anisotropic filtering device in an embodiment. DETAILED DESCRIPTION
[0032] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0033] The anisotropic filtering method and device provided in the embodiments of the present application are mainly aimed at optimizing the anisotropic filtering performance under lossless conditions.
[0034] Keywords involved in the embodiments of the present application: anisotropic filtering (AF for short), bilinear filtering (Bilinear), texture element (Texel for short), pixel (P for short), and sample point (S for short).
[0035] For anisotropy, if a group of four adjacent 2×2 pixels on the screen correspond to a quadrilateral on the texture map that is not a square, it means that there is an angle of inclination between the texture map and the screen, which is anisotropy. If bilinear filtering is used for anisotropy, the information in the distance will be blurry; at this time, anisotropic filtering is needed. Anisotropic filtering can make the texture of inclined objects on the surface clearer and sharper. Anisotropic filtering will perform more bilinear filtering according to the angle formed by the texture map and the screen, so as to achieve better display effects.
[0036] Combined with the above background technology, it can be seen that although the current anisotropic filtering method has better clarity than bilinear filtering, it comes at the cost of significantly reduced performance. Figure 1 , the quadrilateral corresponding to the four pixels P0 to P1 on the texture map is not a square, so there is a certain angle between the texture map and the display screen. According to the angle, a pixel is split into multiple sampling points S (the multiple sampling points S constitute a sampling point sequence), such as Figure 1The pixel point P0 in the image is split into 16 sampling points S, and then bilinear filtering is performed on these 16 sampling points S to obtain 16 intermediate results, and then these 16 intermediate results are weighted and summed according to certain weights to obtain the final result of pixel point P0. It can be seen that although the current anisotropic filtering can achieve better results, the number of sampling points for bilinear filtering is 16 times that of ordinary Bilinear, which greatly affects the performance.
[0037] Next, in order to better illustrate the basic idea of the present application, the process involved in the conventional anisotropic filtering method currently used is briefly introduced. Figure 2 As shown, in the case of AF (anisotropic filtering), step S201 determines whether AF is turned on. When AF is turned on, step S202 is entered to calculate AF parameters (such as LOD, Ratio, Step, SampleNumber, Weight of each S). At this time, the received 4P, i.e., four pixel points, are used to determine an ellipse, and the logarithm of the minor axis of the ellipse is used as the LOD value, Ratio is the ratio of the major and minor axes of the ellipse, and Ratio is rounded up to a multiple of 2 as SampleNumber, i.e., a few x; Step is the distance between two adjacent sampling points S in the UV direction, and the coordinates of all S can be obtained; the weight Weight of the middle S is 1 / Ratio, and the weight Weight of the two far-end sampling points S is (1-(Sample Number-2) / Ratio) / 2. Thus, the information of all sample points S, including their coordinates and weights, is calculated, and steps S203-S206 are entered. All sample points S are subjected to bilinear filtering with sample point S as the granularity. For each sample point S, step S204 calculates the coordinates of 4T (i.e., the corresponding four texture elements) corresponding to each sample point S and retrieves the color information of the corresponding 4T from the memory. Then step S205 calculates the weight of the corresponding 4T according to the coordinates of each sample point S. Then step S206 performs bilinear filtering calculation according to the color information of 4T and its weight, thereby calculating the bilinear filtering calculation result of each sample point S. At the end of the loop, step S207 is entered to accumulate the bilinear filtering calculation results of all sample points S to obtain the final result.
[0038] This application is mainly based on the following three points:
[0039] 1. The spacing between adjacent sampling points S is 1;
[0040] 2. Each texture element T is a square with a side length of 1;
[0041] 3. Based on the previous two points, we can know that among the eight texture elements T corresponding to two adjacent sampling points S, there must be repeated texture elements T.
[0042] The basic idea of this application is that two adjacent sampling points S in point 3 will use at least one same texture element T, so this application avoids the same texture element T from being reused, thereby improving performance.
[0043] Before we deduce the above point 3, we will first explain how to get the nearest four texture elements T through a coordinate. Figure 3 As shown, if you want to take texture elements T0 to T3 as the four nearest texture elements T, then use the center points of texture elements T0 to T3 as vertices to make a square, that is, Figure 3 If the coordinates of a sample point S1 fall within the square surrounded by the left dashed line, then the four texture elements closest to the sample point S1 are texture elements T0 to T3, and the side length of the square surrounded by the dashed line is 1. Figure 3 Similarly, if the coordinates of a sample point S2 fall within the square surrounded by the dashed line on the right, then the four texture elements closest to the sample point S2 are texture elements T4 to T7.
[0044] Based on this, we prove the above point 3:
[0045] Assume that the eight texture elements T corresponding to the adjacent sample points S1 and S2 are not repeated, and are recorded as corresponding to texture elements T0 to T3 and texture elements T4 to T7 respectively. At this time, because the sample point S1 falls within the square surrounded by the dotted line on the left, the distance between the sample point S1 and the middle black solid line is L1>0.5. Similarly, because the sample point S2 falls within the square surrounded by the dotted line on the right, the distance between the sample point S2 and the middle black solid line is L2>0.5. Therefore, the distance between the sample points S1 and S2 is L12>=L1+L2>1, which contradicts the first point mentioned above. It can be seen that at least one texture element T among the eight texture elements T corresponding to two adjacent sample points S is repeated.
[0046] Based on the previous three points, we can know that: when an original pixel point P is split into n sampling points S on the texture map, the number of texture elements T that are actually used for filtering calculations must be less than 4×n.
[0047] From the process involved in the conventional anisotropic filtering method currently used, it can be known that the conventional anisotropic filtering method currently used performs bilinear filtering calculations based on the granularity of sampling point S, and the number of texture elements T that need to be calculated for bilinear filtering is 4×n, and some texture elements T are reused at this time. Therefore, the basic idea of the present application is to avoid repeated filtering calculations for the same texture element T, so as to achieve the purpose of improving performance. To achieve this goal, it is necessary to improve the conventional anisotropic filtering method currently used, and to perform calculations based on the granularity of texture element T instead of sampling point S. Secondly, after obtaining the information of all sampling points S, the weights and other information of all required texture elements T should be calculated immediately.
[0048] The anisotropic filtering method provided by the present application is described below in conjunction with specific embodiments. The method can be executed by a computer device such as a terminal or a server.
[0049] In one embodiment, if Figure 4 As shown, the anisotropic filtering method provided by the present application specifically includes the following steps:
[0050] Step S401, determining a sampling point sequence corresponding to a pixel point on a texture map.
[0051] Among them, the pixel point P can be split into multiple sampling points on the texture map, and the multiple sampling points constitute a sampling point sequence. Exemplarily, the pixel point P can be split into two (AF2x), four (AF4x), eight (AF8x), and sixteen (AF16x) sampling points on the texture map, and the anisotropic filtering method provided in this application can be applied to all AF situations. In this embodiment, the spacing between adjacent sampling points in the sampling point sequence is equal to the side length of the texture element in the texture map, which is 1.
[0052] Step S402, determining the texture element group corresponding to each sampling point in the sampling point sequence on the texture map;
[0053] In this step, for each sampling point S in the sampling point sequence, multiple texture elements T corresponding to each sampling point S are found on the texture map to form a texture element group.
[0054] Specifically, step S402 includes: for each sampling point, according to the coordinates of the sampling point on the texture map, determining a number of texture elements on the texture map that are closest to the sampling point; and obtaining a corresponding texture element group according to the number of texture elements. Among them, the four texture elements T closest to each sampling point S can be determined on the texture map as the corresponding texture element group.
[0055] Step S403, for each sampling point in the sampling point sequence, obtaining the weight of each texture element in the corresponding texture element group;
[0056] In this step, for each sampling point S in the sampling point sequence, it is necessary to first obtain the weight of each texture element T in the corresponding texture element group before performing subsequent filtering calculations.
[0057] Step S404, based on the weight of each texture element in each texture element group, the weight corresponding to the same texture element is accumulated to obtain the total weight of each texture element;
[0058] Since different sampling points S may correspond to some of the same texture elements T, in this step, the weights of each texture element T corresponding to different sampling points S are accumulated as the total weight of the texture element T.
[0059] Step S405, performing filtering calculation based on the total weight of each texture element and the color information of each texture element to obtain filtering calculation results corresponding to each texture element;
[0060] This step performs filtering calculation based on the total weight and color information of each texture element to obtain the corresponding filtering calculation results, wherein the filtering calculation for each texture element may include bilinear filtering. This makes the number of texture elements for filtering calculation necessarily less than 4×n, thereby optimizing the AF performance. Since the calculation of the weight of the texture element has been completed in the previous step, it is no longer necessary to calculate the relevant information in the filtering calculation loop with the texture element as the granularity.
[0061] In some embodiments, step S405 specifically includes: using a number of texture elements as the loop granularity of the filtering calculation, and calculating the filtering calculation result corresponding to each texture element according to the total weight and color information of the corresponding texture elements.
[0062] In this embodiment, the filtering calculation can be performed with, for example, four texture elements T as the loop granularity of the filtering calculation. In each loop, the color information of the corresponding four texture elements T is extracted from the memory. For each texture element T, the filtering calculation result corresponding to each texture element is calculated according to its corresponding total weight and color information.
[0063] The filtering calculation result corresponding to each texture element is calculated according to the total weight and color information of the corresponding texture element, specifically including: for each texture element, the corresponding total weight and color information are multiplied to obtain the filtering calculation result corresponding to each texture element.
[0064] Step S406, obtaining the color information of the pixel point according to the filtering calculation result corresponding to each texture element.
[0065] This step mainly integrates the filtering calculation results corresponding to each texture element T to obtain the color information of the pixel point P. Among them, step S406 can specifically include: accumulating the filtering calculation results corresponding to each texture element to obtain the color information of the pixel point. That is, the filtering calculation results corresponding to each texture element T obtained in step S405 are added together as the color information of the pixel point P.
[0066] Next, the anisotropic filtering method of the present application is described with reference to an example. Figure 5 As shown, in this method, step S501 determines whether AF is turned on, and when AF is turned on, step S502 is entered to calculate AF parameters (such as LOD, Ratio, Step, Sample Number, Weight of each S). After obtaining the information of all sampling points S in step S502, it is necessary to further obtain the weight information of all texture elements T corresponding to these sampling points S. Because different sampling points S will use some of the same texture elements T, the weights of each texture element T corresponding to different sampling points S are accumulated in step S503 as the total weight of the texture element T, and then steps S504 to S506 are entered, that is, four texture elements T are used as the granularity for subsequent bilinear filtering calculations, and the number of texture elements T that actually need bilinear filtering calculations must be less than 4×n, so that AF is optimized, because the weight calculation of the texture element T has been moved to step S503, so there is no need to calculate the relevant information in the loop of steps S504 to S506.
[0067] Regarding the weight merging of each texture element, in one embodiment, based on the weight of each texture element in each texture element group, the weight corresponding to the same texture element is accumulated to obtain the total weight of each texture element, specifically including:
[0068] Based on the coordinates of each texture element in each texture element group, texture elements with the same coordinates are determined as the same texture element; and weights corresponding to the same texture element are accumulated to obtain a total weight of each texture element.
[0069] In this embodiment, for each texture element T in each texture element group, the texture elements T with the same coordinates are combined, their weights are accumulated, and the final weight is the total weight of the texture element T.
[0070] Further, for the weight of each texture element, in one embodiment, for each sampling point in the sampling point sequence, obtaining the weight of each texture element in the corresponding texture element group specifically includes:
[0071] For each sampling point in the sampling point sequence, the weight and coordinate of each texture element in the corresponding texture element group are obtained. That is, for the multiple sampling points S split by the pixel point P on the texture map, the weights of the corresponding texture elements are obtained while the coordinates of the texture elements are obtained, so that the weights of the same texture element can be merged according to the coordinates of the texture elements.
[0072] In the above embodiment, for each sampling point in the sampling point sequence, the weight and coordinates of each texture element in the corresponding texture element group are obtained, which specifically includes: for each sampling point in the sampling point sequence, the weight and coordinates of each texture element in the corresponding texture element group are calculated according to the coordinates and weights of the sampling point. That is, for each sampling point S in the sampling point sequence, a loop is performed with the sampling point S as the granularity, and the coordinates and weights of the corresponding four texture elements T are calculated according to the coordinates and weights of each sampling point S.
[0073] Combination Figure 6 The weight merging with S as the granularity before the filtering calculation with 4T as the granularity (corresponding to step S503) is described. After obtaining the relevant information of all sampling points S in step S502, steps S601 to S603 can be entered, and the sampling point S is used as the granularity for looping, and the coordinates and weights of the four texture elements corresponding to each sampling point S are calculated according to the coordinates and weights of the sampling point S, and then the texture elements with the same coordinates are merged and the weights are accumulated. Finally, the accumulated weight is the total weight of the texture element, which is used for the subsequent filtering calculation with 4T as the granularity.
[0074] It can be seen that although the traditional method only needs to loop the sampling point S once, the method provided in the present application not only has a sampling S loop but also a texture element T loop. Although the number of loops seems to be increased, the number of filtering calculations that actually affect the AF performance is reduced.
[0075] The following describes the efficiency of the anisotropic filtering method provided in this application in improving AF performance.
[0076] The anisotropic filtering method provided in this application is applicable to all AF situations. In addition, all required information is retained during the calculation process, so it is a lossless optimization method. However, the optimization efficiency will be different for different situations. The following mainly describes the best and worst cases of this method.
[0077] Among them, the two factors that affect the optimization efficiency are: ① the number n of sampling points S after a pixel point P is split; ② the angle θ between the connecting line of all sampling points S and the horizontal direction. It can be understood that when the number n of sampling points S is larger, the number of texture elements T is also larger; when the number n of sampling points S is smaller, the number of texture elements T is also smaller. Therefore, the number n of sampling points S does not constitute a factor that affects the monotonicity of the function of the change in the number of texture elements T. Therefore, for the sake of simplicity of calculation, the number n of sampling points S is set to 16, and the influence of the angle θ on the number of texture elements T is mainly explained. Since this application mainly reduces the number of texture elements T for filtering calculations, the ratio of the reduced number of texture elements T to 4×n (the number of texture elements T that need to be filtered and calculated with S as the granularity) is used as the optimization efficiency.
[0078] refer to Figure 7 , the number of texture elements T that need to be calculated is equivalent to the area of the enclosed parallelogram. The height of the parallelogram is (n+1)*sinθ, and the length of the base will change with the change of θ. The closer the angle θ is to 0°, the longer the length of the base is, and the closer it is to n+1; and the closer the angle θ is to 90°, the closer the length of the base is to 2. Due to the symmetry of its changes, only the changes of θ∈[45°, 90°] are explained here. Therefore, we first need to find the relationship between the base and the angle θ. This can be obtained from Figure 7 As can be seen from the figure, the length of the bottom edge is equal to the average number of texture elements T occupied by each row, so the average can be obtained by calculating the expected value. Since the distance between adjacent sampling points S is 1, it can be concluded that the distance between adjacent sampling points S in the horizontal and vertical directions is cosθ and sinθ respectively.
[0079] refer to Figure 8 , if the first sampling point S of two adjacent sampling points S falls within 1-cosθ in the horizontal mapping, and the second sampling point S still falls within the dotted rectangle, then no new texture element T will be used in the horizontal direction; if the first sampling point S falls within the range of cosθ, the second sampling point S will use a new texture element T, so in this case, there will be three texture elements T in this row. Therefore, the length of the bottom edge is: 2*(1-cosθ)+3*cosθ. Then, the number of texture elements T used is: (2*(1-cosθ)+3*cosθ)*(n+1)*sinθ. Analysis of the derivative function of the function shows that the maximum value is obtained at around 68°; the minimum value is obtained at around 45° and 90°.
[0080] Substituting these angles into the calculation, we can see that in the worst case, approximately 37.43 texture elements T need to be calculated, and in the best case, approximately 34 texture elements T need to be calculated. Therefore, compared with the 64 texture elements T that need to be calculated with S as the granularity, they are approximately improved by 41.5% and 46.875% respectively. In addition, according to the above formula, there is a term n+1, which shows that: when n is larger, the effect of 1 on the formula is smaller. This means that when the number of sampling points S is larger, the performance improvement is more obvious.
[0081] The following uses θ of 90° and a non-special angle as examples to illustrate the performance improvement.
[0082] For θ of 90°:
[0083] When anisotropic filtering generates multiple sampling points S, the distance between two adjacent sampling points S is 1, and each sampling point S is filtered in a bilinear filtering manner. The filtering method of bilinear filtering has been introduced above, that is, the four texture elements T around the sampling point S are used to calculate a new color information as the value of the pixel point P according to the corresponding weight. Taking AF4x as an example, as shown in Figure 9(a), P shows the position of a pixel corresponding to the texture map. This pixel point P is split into four sampling points S, namely S0, S1, S2 and S3. Among them, the sampling point S0 uses the four nearest texture elements T for filtering, namely texture elements T0, T1, T2 and T3; the sampling point S1 uses texture elements T2, T3, T4 and T5; the sampling point S2 uses texture elements T4, T5, T6 and T7; the sampling point S3 uses texture elements T6, T7, T8 and T9. It can be seen that texture elements T2 to T7 are used twice. Therefore, the present application calculates the texture elements T0 to T3 of the sampling point S0 and the texture elements T2 and T3 of the sampling point S1 together, and calculates the texture elements T4 and T5 of the sampling point S1, the texture elements T4 to T7 of the sampling point S2, and the texture elements T6 and T7 of the sampling point S3 together, so as to avoid repeatedly using the same texture elements for calculation in the multiplier, thereby improving performance.
[0084] Specifically, according to the method provided by the present application, the coordinates and weights of the corresponding four texture elements T are calculated according to the coordinates and weights of each sampling point S. That is, the weights of the texture elements T0 to T3 corresponding to the sampling point S0 are Weight_S0_T0, Weight_S0_T1, Weight_S0_T2, and Weight_S0_T3; the weights of the texture elements T2 to T5 corresponding to the sampling point S1 are Weight_S1_T2, Weight_S1_T3, Weight_S1_T4, and Weight_S1_T5; the weights of the texture elements T4 to T7 corresponding to the sampling point S2 are Weight_S2_T4, Weight_S2_T5, Weight_S2_T6, and Weight_S2_T7; the weights of the texture elements T6 to T9 corresponding to the sampling point S3 are Weight_S3_T6, Weight_S3_T7, Weight_S3_T8, and Weight_S3_T9.
[0085] Then, the texture elements T corresponding to all sampling points S are merged according to equal coordinates, and the weights of the texture elements T with the same coordinates are accumulated, and the obtained weight is used as the total weight of the texture element T. That is: the weight of texture element T0 is Weight_S0_T0; the weight of texture element T1 is Weight_S0_T1; the weight of texture element T2 is (Weight_S0_T2+Weight_S1_T2); the weight of texture element T3 is (Weight_S0_T3+Weight_S1_T3); the weight of texture element T4 is (Weight_S1_T4+Weight_S2_T4); the weight of texture element T5 is (Weight_S1_T5+Weight_S2_T5); the weight of texture element T6 is (Weight_S2_T6+Weight_S3_T6); the weight of texture element T7 is (Weight_S2_T7+Weight_S3_T7); the weight of texture element T8 is Weight_S3_T8; the weight of texture element T9 is Weight_S3_T9.
[0086] At this point, the coordinates and weight information of all the texture elements T needed have been obtained, and then a loop is performed with 4T as the granularity. Bilinear filtering calculation is performed based on the total weight and color information obtained, and all the filtering calculation results split from the pixel point P are added up to get the final result of this pixel point P. The above process can be expressed by the following calculation formula: P = S0*Weight_S0+S1*Weight_S1+S2*Weight_S2+S3*Weight_S3 = T0*Weight_S0_T0+T1*Weight_S0_T1+T2*Weight_S0_T2+T3*Weight_S0_T3+T2*Weight_S1_T2+T3*Weight_S1_T3+T4*Weight_S1_T4+T5*Weight_S1_T5+T4*Weight_S2_T4+T5*Weight_S2_T5+T6*Weight t_S2_T6+T7*Weight_S2_T7+T6*Weight_S3_T6+T7*Weight_S3_T7+T8*Weight_S3_T8+T9*Weight_S3 _T9=T0*Weight_S0_T0+T1*Weight_S0_T1+T2*(Weight_S0_T2+Weight_S1_T2)+T3*(Weight_S0_T3+W eight_S1_T3)+T4*(Weight_S1_T4+Weight_S2_T4)+T5*(Weight_S1_T5+Weight_S2_T5)+T6*(Weight _S2_T6+Weight_S3_T6)+T7*(Weight_S2_T7+*Weight_S3_T7)+T8*Weight_S3_T8+T9*Weight_S3_T9.
[0087] According to the above calculations, the final result is not affected after optimization, so the optimization does not lose accuracy. In addition, the original 4 filterings (16 multiplications) are required, but after optimization, only 2.5 filterings (10 multiplications) are required, and the performance is improved by about 37.5%. The more sampling points AF generates, the more significant the performance improvement. When AF16x, the performance can be improved by up to about 46.875%.
[0088] Referring to FIG9(b), for an example in which θ is a non-special angle and is AF8x, similarly, a loop is performed with the sampling point S as the granularity to calculate the coordinates and weights of the four texture elements T corresponding to each sampling point S. That is: the weights of the texture elements T0, T1, T2, and T3 corresponding to the sampling point S0 are Weight_S0_T0, Weight_S0_T1, Weight_S0_T2, and Weight_S0_T3; the weights of the texture elements T2, T3, T5, and T6 corresponding to the sampling point S1 are Weight_S1_T2, Weight_S1_T3, Weight_S1_T5, and Weight_S1_T6; the weights of the texture elements T4, T5, T7, and T8 corresponding to the sampling point S2 are Weight_S2_T4, Weight_S2_T5, Weight_S2_T7, and Weight_S2_T8; the weights of the texture elements T7, T8, T10, and T11 corresponding to the sampling point S3 are Weight_S3_T7, Weight_S3_T8, Weight_S3_T10, and Weight_S3_T11; the weights of the texture elements S4 and T5 are Weight_S1_T2, Weight_S1_T3, Weight_S1_T5, and Weight_S1_T6. The weights of T9, T10, T13, and T14 are Weight_S4_T9, Weight_S4_T10, Weight_S4_T13, and Weight_S4_T14; the weights of texture elements T13, T14, T16, and T17 corresponding to texture element S5 are Weight_S5_T13, Weight_S5_T14, Weight_S5_T16, and Weight_S5_T17; the weights of texture elements S6 and T7 are Weight_S7_T8, Weight_S7_T9, Weight_S7_T10, Weight_S7_T13, and Weight_S7_T14. The weights of the corresponding texture elements T12, T13, T15, and T6 are Weight_S6_T12, Weight_S6_T13, Weight_S6_T15, and Weight_S6_T16; the weights of the texture elements T15, T16, T18, and T19 corresponding to texture element S7 are Weight_S7_T15, Weight_S7_T16, Weight_S7_T18, and Weight_S7_T19.
[0089] Then, the texture elements T corresponding to all sampling points S are merged according to the equal coordinates, and the weights of the texture elements T with the same coordinates are accumulated, and the obtained weight is used as the total weight of the texture element T. That is: the weight of texture element T0 is Weight_S0_T0; the weight of texture element T1 is Weight_S0_T1; the weight of texture element T2 is (Weight_S0_T2+Weight_S1_T2); the weight of texture element T3 is (Weight_S0_T3+Weight_S1_T3); the weight of texture element T4 is Weight_S2_T4; the weight of texture element T5 is (Weight_S1_T5+Weight_S2_T5); the weight of texture element T6 is Weight_S1_T6; the weight of T7 is (Weight_S2_T7+Weight_S3_T7); the weight of texture element T8 is (Weight_S2_T8+Weight_S3_T8); the weight of texture element T9 is Weight_S4_T9; the weight of texture element T10 is (Weight_S3_T10+Weight_S3_T11+Weight_S3_T12+Weight_S3_T13+Weight_S3_T14+Weight_S3_T15+Weight_S3_T16+Weight_S3_T17+Weight_S3_T18+Weight_S3_T19+ ... eight_S4_T10); the weight of texture element T11 is Weight_S3_T11; the weight of texture element T12 is Weight_S6_T12; the weight of texture element T13 is (Weight_S4_T13+Weight_S5_T13+Weight_S6_T13); the weight of texture element T14 is (Weight_S4_T14+Weight_S5_T14); the weight of texture element T15 is (Weight_S6_T15+Weight_S7_T15); the weight of texture element T16 is (Weight_S5_T16+Weight_S6_T16+Weight_S7_T16); the weight of texture element T17 is Weight_S5_T17; the weight of texture element T18 is Weight_S7_T18; the weight of texture element T19 is Weight_S7_T19.
[0090] Then loop with 4T as the granularity, perform bilinear filtering calculation according to the total weight and color information, add up all the filtering calculation results split from the pixel point P, and get the final result of this pixel point P. The above process can be expressed by the following calculation formula: P = T0*Weight_S0_T0+T1*Weight_S0_T1+T2*(Weight_S0_T2+Weight_S1_T2)+T3*(Weight_S0_T3+Weight_S1_T3)+T4*Weight_S2_T4+T5*(Weight_S1_T5+Weight_S2_T5)+T6*Weight_S1_T6+T7*(Weight_S2_T7+Weight_S3_T7)+T8*(Weight_S2_T8+Weight_S3_T8)+T9*Weight_S4_T9+T10*(Weight_S3_T10 0+Weight_S4_T10)+T11*Weight_S3_T11+T12*Weight_S6_T12+T13*(Weight_S4_T13+Weight_S5_T13+Weight_S6_T13)+T14*(Weight_S4_T14+Weight_S5_T14)+ T15*(Weight_S6_T15+Weight_S7_T15)+T16*(Weight_S5_T16+Weight_S6_T16+Weight_S7_T16)+T17*Weight_S5_T17+T18*Weight_S7_T18+T19*Weight_S7_T19.
[0091] From the above process, it can be seen that the original method with S as the granularity needs 8 Bilinear Filter calculations (32 multiplications); the present application only needs 5 Bilinear Filter calculations according to 4T loops, that is, 20 multiplications. The performance is improved by about 37.5%.
[0092] Therefore, based on the original AF calculation method, this application improves the performance by selecting and merging texture elements. The main idea is to avoid repeated operations on the same texture elements to dynamically reduce sampling points and optimize anisotropic filtering performance under lossless conditions. The main advantages in processing flow and technical effects are as follows:
[0093] ① This application is a lossless optimization method, which can ensure that all required texture element T information is calculated into the final result;
[0094] ② The more split sampling points S are, the more obvious the performance improvement is, which can be close to 50%;
[0095] ③ This application will perform Bilinear calculations with S as the granularity, and modify it to calculate with 4T as the granularity. In terms of the process, it is only necessary to advance the coordinate and weight calculation of the texture element T in the original method to the outside of the 4T loop.
[0096] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0097] Based on the same inventive concept, the embodiment of the present application also provides an anisotropic filtering device for implementing the anisotropic filtering method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations of one or more anisotropic filtering device embodiments provided below can refer to the limitations of the anisotropic filtering method above, and will not be repeated here.
[0098] In one embodiment, Fig.10 As shown, an anisotropic filtering device is provided, and the device 1100 includes:
[0099] The sampling point determination module 1001 is used to determine a sampling point sequence corresponding to a pixel point on a texture map; wherein the spacing between adjacent sampling points in the sampling point sequence is equal to the side length of a texture element in the texture map;
[0100] A texture element determination module 1002 is used to determine a texture element group corresponding to each sampling point in the sampling point sequence on the texture map;
[0101] A weight acquisition module 1003 is used to acquire the weight of each texture element in the corresponding texture element group for each sampling point in the sampling point sequence;
[0102] The weight accumulation module 1004 is used to accumulate the weight corresponding to the same texture element based on the weight of each texture element in each texture element group to obtain the total weight of each texture element;
[0103] A filtering calculation module 1005 is used to perform filtering calculation based on the total weight of each texture element and the color information of each texture element to obtain filtering calculation results corresponding to each texture element;
[0104] The result processing module 1006 is used to obtain the color information of the pixel point according to the filtering calculation result corresponding to each texture element.
[0105] In one embodiment, the weight accumulation module 1004 is used to determine the texture elements with the same coordinates as the same texture element based on the coordinates of each texture element in each texture element group; and accumulate the weights corresponding to the same texture element to obtain the total weight of each texture element.
[0106] In one embodiment, the weight acquisition module 1003 is used to acquire the weight and coordinates of each texture element in the corresponding texture element group for each sampling point in the sampling point sequence.
[0107] In one embodiment, the weight acquisition module 1003 is used to calculate the weight and coordinates of each texture element in the corresponding texture element group according to the coordinates and weight of each sampling point in the sampling point sequence.
[0108] In one embodiment, the filtering calculation module 1005 is used to use a number of texture elements as the loop granularity of filtering calculation, and calculate the filtering calculation result corresponding to each texture element according to the total weight and color information of the corresponding texture elements.
[0109] In one embodiment, the filtering calculation module 1005 is used to multiply the corresponding total weight and color information for each texture element to obtain a filtering calculation result corresponding to each texture element.
[0110] In one embodiment, the result processing module 1006 is used to accumulate the filtering calculation results corresponding to each texture element to obtain the color information of the pixel.
[0111] In one embodiment, the texture element determination module 1002 is used to determine, for each sampling point, a number of texture elements on the texture map that are closest to the sampling point according to the coordinates of the sampling point on the texture map; and obtain the corresponding texture element group according to the number of texture elements.
[0112] In one embodiment, the filtering calculation comprises bilinear filtering.
[0113] Each module in the above anisotropic filtering device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.
[0114] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0115] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0116] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. An anisotropic filtering method, characterized in that: The method comprises: Determine a sampling point sequence corresponding to a pixel point on a texture map; wherein a distance between adjacent sampling points in the sampling point sequence is equal to a side length of a texture element in the texture map; Determining a texture element group corresponding to each sampling point in the sampling point sequence on the texture map; comprising: for each sampling point, determining a number of texture elements on the texture map that are closest to the sampling point according to the coordinates of the sampling point on the texture map; and obtaining the corresponding texture element group according to the number of texture elements; For each sampling point in the sampling point sequence, obtaining a weight of each texture element in the corresponding texture element group; Based on the weight of each texture element in each texture element group, texture elements with the same coordinates are determined as the same texture element; weights corresponding to the same texture element are accumulated to obtain a total weight of each texture element; Performing filtering calculation based on the total weight of each texture element and the color information of each texture element to obtain filtering calculation results corresponding to each texture element; including: taking a number of texture elements as the loop granularity of filtering calculation, multiplying the corresponding total weight and color information for each texture element to obtain filtering calculation results corresponding to each texture element; Obtaining the color information of the pixel point according to the filtering calculation results corresponding to each of the texture elements; including: accumulating the filtering calculation results corresponding to each of the texture elements to obtain the color information of the pixel point.
2. The method according to claim 1, characterized in that The step of obtaining the weight of each texture element in the corresponding texture element group for each sampling point in the sampling point sequence includes: For each sampling point in the sampling point sequence, the weight and coordinates of each texture element in the corresponding texture element group are obtained.
3. The method according to claim 2, characterized in that The step of obtaining the weight and coordinates of each texture element in the corresponding texture element group for each sampling point in the sampling point sequence includes: For each sampling point in the sampling point sequence, the weight and coordinate of each texture element in the corresponding texture element group are calculated according to the coordinate and weight of the sampling point.
4. The method according to any one of claims 1 to 3, characterized in that: The filtering calculation includes bilinear filtering.
5. The method according to claim 1, characterized in that The spacing between adjacent sampling points in the sampling point sequence and the side length of the texture element in the texture map are both 1.
6. An anisotropic filtering device, characterized in that: The device comprises: A sampling point determination module, used to determine a sampling point sequence corresponding to a pixel point on a texture map; wherein the spacing between adjacent sampling points in the sampling point sequence is equal to the side length of a texture element in the texture map; a texture element determination module, configured to determine a texture element group corresponding to each sampling point in the sampling point sequence on the texture map; and to determine, for each sampling point, a number of texture elements on the texture map that are closest to the sampling point according to the coordinates of the sampling point on the texture map; and to obtain the corresponding texture element group according to the number of texture elements; A weight acquisition module, used for acquiring the weight of each texture element in the corresponding texture element group for each sampling point in the sampling point sequence; A weight accumulation module is used to determine the texture elements with the same coordinates as the same texture element based on the weight of each texture element in each texture element group; and to accumulate the weights corresponding to the same texture element to obtain the total weight of each texture element; A filtering calculation module, used for performing filtering calculation based on the total weight of each texture element and the color information of each texture element to obtain filtering calculation results corresponding to each texture element; used for taking a plurality of texture elements as the loop granularity of filtering calculation, multiplying the corresponding total weight and color information for each texture element to obtain filtering calculation results corresponding to each texture element; The result processing module is used to obtain the color information of the pixel point according to the filtering calculation results corresponding to each texture element; and is used to accumulate the filtering calculation results corresponding to each texture element to obtain the color information of the pixel point.
7. The device according to claim 6, characterized in that The weight acquisition module is used to acquire the weight and coordinates of each texture element in the corresponding texture element group for each sampling point in the sampling point sequence.
8. The device according to claim 7, characterized in that The weight acquisition module is used to calculate the weight and coordinates of each texture element in the corresponding texture element group according to the coordinates and weight of each sampling point in the sampling point sequence.
9. The device according to any one of claims 6 to 8, characterized in that The filtering calculation includes bilinear filtering.
10. The device according to claim 6, characterized in that The spacing between adjacent sampling points in the sampling point sequence and the side length of the texture element in the texture map are both 1.
Citation Information
Patent Citations
Image processing apparatus and method, recording medium, and program
CN101079949A
Image plotting method and image plotting equipment using omnidirectional different pattern mapping
CN1845178A