Method for optimizing bilinear interpolation and nearest neighbor interpolation serration

Through the step-by-step pixel acquisition method, the problem of sawtoothing of bilinear interpolation and nearest neighbor interpolation during image scaling is solved, and image details are retained and computational efficiency is improved.

CN120031736APending Publication Date: 2025-05-23HEFEI JUNZHENG TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311590007.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-11-22
Publication Date
2025-05-23

AI Technical Summary

Technical Problem

Bilinear interpolation and nearest neighbor interpolation are prone to jagging when scaling images, and the calculation amount of trilinear interpolation is too large and difficult to be used in industry.

Method used

The method of taking pixels in step-by-step, obtaining the scaling ratios of width and height, inversely pushing the input pixel point coordinates, selecting 6 coordinate point values ​​to participate in the calculation, and setting their weights to 1 to eliminate the aliasing.

Benefits of technology

Effectively eliminate jagging during image scaling, maximize image details, and reduce the amount of calculation to meet industrial time requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120031736A_ABST
    Figure CN120031736A_ABST
Patent Text Reader

Abstract

The invention provides a method for optimizing bilinear interpolation and nearest neighbor interpolation jagging, pixels are taken in a stepped manner, and the method comprises the following steps: S1, obtaining a w-direction scaling: Widthscale = (float) srcw / (float) dstw, Widthscale = (float) srcw / (float) dstw, Widthscale = (float) srcw / (float) dstw; s2, obtaining a scaling ratio in an h direction: Height scale = (float) srch / (float) dsth; s3, calculating coordinates of pixel points which are output and mapped back to input; s4, selecting three image key coordinates and three image fuzzy coordinates; s5, judging whether the boundary is crossed or not, and correcting a coordinate point ifx0gt; srcw, srcw; x0 is equal to srcw; ify0gt, ify0gt; srch is carried out; y0 is equal to srch; s6, the image key coordinates and the image fuzzy coordinates are endowed with the same weight so as to expect that the image fuzzy coordinates can play a key role in image generation, so that sawteeth are eliminated, and pixel point values of output coordinates (x, y) are equal to the sum average of pixel point values of six input selected coordinates: Dst (x, y) = (a + b + c + d + e + f) / 6.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of digital image and video processing, and in particular relates to a method for optimizing bilinear interpolation and nearest neighbor interpolation aliasing. Background Art

[0002] In the existing technology, with the development of science and technology, especially the leap of artificial intelligence technology, more and more methods can be used in the field of image and video processing. Commonly used methods in image processing include:

[0003] Bilinear interpolation, also known as bilinear interpolation, is a common image interpolation method, widely used in signal processing, digital image and video processing, etc. Mathematically, bilinear interpolation is an extension of linear interpolation with an interpolation function of two variables. Its core idea is to perform linear interpolation in two directions respectively.

[0004] Nearest neighbor interpolation, also known as zero-order interpolation, is a commonly used image interpolation method, widely used in signal processing, digital image and video processing, etc. It is to make the gray value of the transformed pixel equal to the gray value of the nearest input pixel.

[0005] However, the above prior art has the following defects:

[0006] 1. Although bilinear interpolation has small calculation amount, fast speed and high quality of scaled images, it will inevitably produce jagged images when scaling images. The larger the scaling ratio, the more likely it is to produce jagged images.

[0007] 2. Although the nearest neighbor interpolation has small calculation amount, fast speed and good quality of scaled image, it is more of a single enlargement of pixels, which makes the lines and shapes appear more uneven and the jagged phenomenon is more serious.

[0008] Currently, the only known way to effectively solve the jagged phenomenon is to use trilinear interpolation, which is a method of linear interpolation on a tensor convolution grid of three-dimensional discrete sampling data. This tensor grid may have any non-overlapping grid points in each dimension. This method linearly approximates the value of a point (x, y, z) on a local rectangular prism using the data points on the grid. Although trilinear interpolation works well, the computational complexity of trilinear interpolation is three times that of bilinear interpolation. It is not advisable in industry to optimize the jaggedness caused by bilinear interpolation and nearest neighbor interpolation at such a high time cost.

[0009] In addition, the commonly used terms in the prior art include:

[0010] Aliasing: Aliasing refers to the uneven lines that can be seen from diagonal lines and edges of objects in an image. Summary of the invention

[0011] In order to solve the above problems, the purpose of this application is to optimize the method of bilinear interpolation and nearest neighbor interpolation jaggedness, use the step-by-step pixel extraction method to blur the jagged area of ​​the generated image while maximally ensuring the image details, eliminate the jaggedness of the generated image, and finally meet the industrial time requirements. Finally, the jaggedness generated when bilinear interpolation and nearest neighbor interpolation are used to scale images in image processing is eliminated.

[0012] Specifically, the present invention provides a method for optimizing bilinear interpolation and nearest neighbor interpolation aliasing, the method utilizing stepwise pixel fetching, comprising the following steps:

[0013] S1, get the scaling ratio in the width w direction, input image width src_w / output image width dst_w, located in the image coordinate system of width and height, the scaling ratio in the w direction is as follows:

[0014] Width_scale=(float)src_w / (float)dst_w;

[0015] S2, get the scaling ratio in the height h direction, input image height src_h / output image height dst_h, located in the image coordinate system of width and height, the scaling ratio in the h direction is as follows:

[0016] Height_scale=(float)src_h / (float)dst_h;

[0017] S3, inverting the input pixel coordinates through the output pixel coordinates, including:

[0018] S3.1. Calculate the wide x-coordinate point, where x is the output wide coordinate point and x0 is the reversed input wide coordinate point:

[0019] x0 = (int)x * width_scale;

[0020] S3.2. Calculate the high y coordinate point, where y is the output high coordinate point and y0 is the high coordinate point in reverse order:

[0021] y0 = (int)y * height_scale;

[0022] S4, select 6 coordinate point values ​​to participate in the calculation. The selected coordinates are divided into image key coordinates and image fuzzy coordinates. The image key coordinate pixels obtain image key information, and the image fuzzy coordinates obtain the edge information of the pixel coordinate points. The number of image key coordinates and image fuzzy coordinates needs to be balanced and moderate. Therefore, three image key coordinates and three image fuzzy coordinates are selected, including:

[0023] S4.1, image key coordinates:

[0024] a=(x0,y0),b=(x0+1,y0),c=(x0+2,y0+1);

[0025] (x0, y0) is the input coordinate point inferred from the output coordinate (x, y) according to the formula in step S3, (x0+1, y0) and (x0+2, y0+1) are input coordinate points whose x0 coordinate is within 3 and y0 coordinate is within 2 of (x0, y0), and are strongly correlated with the pixel value of (x0, y0);

[0026] S4.2, image blur coordinates:

[0027] d=(x0+3,y0+1),e=(x0+4,y0+2),f=(x0+5,y0+2);

[0028] Similar to step S4.1, (x0+3,y0+1), (x0+4,y0+2), (x0+5,y0+2) are input coordinate points whose x0 coordinates are outside 3 and equal to 3, and whose y0 coordinates are outside 1 and include 1, and are weakly correlated with the pixel value of the coordinate (x0,y0);

[0029] S5, determine whether it is out of bounds, and correct its coordinate point according to x0 and y0 in step S4:

[0030] If x0>src_w; then x0=src_w;

[0031] If the x coordinate of the inverse input is greater than the input width, x0 takes src_w;

[0032] If y0>src_h; then y0=src_h;

[0033] If the h coordinate of the inverse input is greater than the input height, y0 takes src_h;

[0034] S6, the pixel value of the output coordinate (x, y) is derived from the pixel values ​​of the six coordinate points in step S4, and the weights of the six pixel points are all set to 1, that is, the image key coordinates and the image blur coordinates are given equal weights, in the hope that the image blur coordinates can play a key role in generating the image, thereby eliminating aliasing; therefore, the pixel value of the output coordinate Dst (x, y) is obtained by: Dst (x, y) = (1*a+1*b+1*c+1*d+1*e+1*f) / 6;

[0035] The pixel value of the output coordinate (x, y) is equal to the pixel value of the 6 coordinates obtained by S4 multiplied by their respective weights 1 and divided by the total number of coordinate points 6;

[0036] The pixel value of the output coordinate (x, y) is equal to the average of the 6 input coordinate pixel values: Dst(x, y) = (a+b+c+d+e+f) / 6.

[0037] The method is optimized by using the MUX3 instruction set, wherein the MUX3 is a set based on simd instructions, further:

[0038] The step S1 includes: calculating the maximum number of output image coordinate points width_cycs that can be processed in one batch:

[0039] 1) A register can store up to 512 bits of data, that is, 64 8-bit data, so the maximum number of output data that can be processed at one time width_cycs is 64;

[0040] 2) The register read bit format is only o(256bit) / q(128bit) / d(64bit) / d(32bit), so the number of output data that can be processed at one time width_cycs can only be 1, 2, 4, 8, 16, 32;

[0041] 3) The optimization is to obtain the input data through the relational array through the gshufvb instruction in the MXU3 instruction set to participate in the calculation. The gshufvb instruction obtains the data of the corresponding coordinate points of the input image through the lower 6 bits of each byte. The number that 6 bits can represent is 0-63, so the difference between the maximum and minimum values ​​of each batch of data in the relational array cannot be higher than 63; therefore, when the input data is 8 bits, the calculation formula of width_cycs is:

[0042] Width_scale = (float)src_w / (float)dst_w; (scaling ratio on width)

[0043] Width_cycs=(int)64 / width_scale;

[0044] The mapping relationship is as follows (width_cycs has nothing to do with the scaling in the h direction):

[0045] Relational Width_cycs Greater than or equal to 2 and less than 4 2 Greater than or equal to 4 and less than 8 4 Greater than or equal to 8 and less than 16 8 Greater than or equal to 16 and less than 32 16 Greater than 32 32

[0046] The size of width_cycs is obtained through step S3, and then according to the size of width_cycs, the coordinate correspondence is saved in the array in advance, which can save a lot of calculation time. The X and Y coordinates are calculated as follows:

[0047]

[0048]

[0049] Therefore, the corresponding relationship between output and input is stored in the relation array in advance;

[0050] According to step S6, the corresponding input data is obtained by using the relational array for parallel calculation, that is, a total of 6 groups of data are obtained, each group of data contains four input coordinate points, and the pixel values ​​of four output coordinate points are obtained. The above operation can be achieved by using the gshufvb instruction in the MXU3 instruction set; then the basic addition FADDW and multiplication FMULW instructions in the MXU3 instruction set are used to obtain four output values ​​in parallel at one time, reducing redundant calculations and optimizing time efficiency.

[0051] In step S1, assuming that src_w=64, dst_w=6, width_scale=10.667, then:

[0052] Width_scale 10.667 dst coordinate in the x direction 0123456 Src in the x direction 0102132425364

[0053] When width_cycs is equal to 6, the maximum and minimum values ​​of the src coordinates stored in a batch are already greater than 63, so according to the above relationship, width_cycs is equal to 4, and 4 coordinate points are calculated at a time in a batch.

[0054] The gshufvb instruction and specific implementation process are as follows:

[0055]

[0056] The method uses the correspondence between the output image and the input image, stores the relation array in advance in the array, and then obtains data in batches from the relation array and the input data for calculation through the gshufvb instruction. When the relation array stores 32 data, the time optimization efficiency is maximum, and the optimization efficiency exceeds 98%.

[0057] Therefore, the advantages of this application are:

[0058] The advantages of the method proposed in this paper over bilinear interpolation and nearest neighbor interpolation are mainly anti-aliasing and time optimization:

[0059] a. Anti-aliasing: Each pixel of an image has a certain correlation with the surrounding pixels. The farther the distance between pixels, the shallower the correlation, and the closer the distance between pixels, the deeper the correlation. As shown below, this article uses a step-by-step pixel acquisition method to obtain the required 6 pixel values ​​(1, 2, 3, 4, 5, 6), and then adds the 6 pixel values ​​to average and finally generates the final pixel value of the image. Among them, 1 is the input pixel closest to it after the image transformation, and 2 and 3 are pixels with strong correlation with it, so as to ensure the pixel details of the generated image. Pixels 4, 5 and 6 are far away from pixel 1 and have a weaker correlation with pixel 1. The pixel values ​​of these three pixels are included in it to blur the generated image, so as to achieve the effect of eliminating aliasing.

[0060] 1 2 3 4 5 6

[0061] From bilinear interpolation ( Figure 2 ) and the step value of this method ( Figure 3 ) can be clearly seen from the comparison chart that the upper left corner of the image generated by bilinear interpolation has obvious jaggedness, while the upper left corner of the image generated by step value has significantly less jaggedness, which greatly improves the effect while ensuring the amount of calculation and the quality of the generated image.

[0062] b. Time optimization: Although the algorithm proposed in this paper selects more coordinate points than bilinear interpolation, it reduces the calculation of weights and a large number of multiplication calculations and weight values, has less calculation volume, optimizes the corresponding time, and better meets industrial needs. The time optimization ratio of the step pixel method proposed in this paper compared to the bilinear interpolation image scaling method is 7%. BRIEF DESCRIPTION OF THE DRAWINGS

[0063] The drawings described herein are used to provide a further understanding of the present invention, constitute a part of this application, and do not constitute a limitation of the present invention.

[0064] Figure 1 It is a schematic diagram of the process of the present application method.

[0065] Figure 2 It is a schematic diagram obtained by using bilinear interpolation in the prior art.

[0066] Figure 3 This is a schematic diagram obtained by adopting step-by-step value selection in the method of this application. DETAILED DESCRIPTION

[0067] In order to more clearly understand the technical content and advantages of the present invention, the present invention is now further described in detail in conjunction with the accompanying drawings.

[0068] In the prior art, when bilinear interpolation is used to scale an image, although the surface of the pixel area is consistent, the slope is inconsistent. In addition, when bilinear interpolation is used to scale an image too much, the image details will be degraded, making the slope inconsistent, so that the scaled image will produce uneven lines (jaggies) one level at a time. The nearest neighbor interpolation uses the grayscale value of the transformed pixel to be equal to the grayscale value of the input pixel closest to it. When enlarging an image, it is a multiple enlargement of a single pixel. When shrinking an image, the nearest pixel point is used to replace the pixel value of the entire area, which will lose a lot of image details, making the jaggedness of the generated image more serious.

[0069] Currently, the only known effective solution to the aliasing phenomenon is to use trilinear interpolation. Although trilinear interpolation works well, the computational complexity of trilinear interpolation is three times that of bilinear interpolation. It is not advisable in industry to optimize the aliasing caused by bilinear interpolation and nearest neighbor interpolation at such a high cost of time. Therefore, this paper proposes a method to optimize the aliasing of bilinear interpolation and nearest neighbor interpolation (a step-by-step pixel extraction method), so that the generated image can maximize the image details while blurring the aliased area and eliminating the aliasing of the generated image. Finally, it can also meet the time requirements of industry.

[0070] like Figure 1 As shown, this application proposes a method for optimizing bilinear interpolation and nearest neighbor interpolation jaggedness. The main process of the proposed step-by-step pixel acquisition method and idea is as follows

[0071] S1, get the scaling ratio in the w (width) direction (input image width (src_w) / output image width (dst_w):

[0072] Width_scale=(float)src_w / (float)dst_w;

[0073] S2, get the scaling ratio in the h (height) direction (input image height (src_h) / output image height (dst_h):

[0074] Height_scale=(float)src_h / (float)dst_h;

[0075] S3, inverting the input pixel coordinates through the output pixel coordinates, including:

[0076] S3.1. Calculate the x (width) coordinate point (x is the output width coordinate point, x0 is the reverse input width coordinate point):

[0077] x0 = (int)x * width_scale;

[0078] S3.2. Calculate the coordinate point in the y (height) direction (y is the output height coordinate point, y0 is the reverse input height coordinate point):

[0079] y0 = (int)y * height_scale;

[0080] S4, in the image, when the coordinate point is closer to the starting coordinate point, the greater the correlation between the captured pixel value and the starting point pixel value, and when the coordinate point is farther from the starting point, the smaller the correlation between the captured pixel value and the starting point pixel value. Bilinear interpolation cannot blur the jagged edges and eliminate the jagged edges because the four selected coordinate points are highly correlated. Therefore, compared with bilinear interpolation, this paper will select an additional part of pixel values ​​with less correlation to participate in the final result calculation. The selected coordinates are divided into image key coordinates and image fuzzy coordinates. The image key coordinate pixels obtain the image key information, and the image fuzzy coordinates obtain the edge information of the pixel coordinate points. The number of image key coordinates and image fuzzy coordinates needs to be balanced and moderate. Therefore, this paper selects three image key coordinates and three image fuzzy coordinates:

[0081] S4.1, image key coordinates:

[0082] a=(x0,y0),b=(x0+1,y0),c=(x0+2,y0+1);

[0083] (x0, y0) is the input coordinate point inferred from the output coordinate (x, y) according to the S3 formula. (x0+1, y0) and (X0+2, y0+1) are input coordinate points whose x0 coordinate is within 3 and y0 coordinate is within 2 of (x0, y0), and are strongly correlated with the pixel value of (x0, y0).

[0084] S4.2, image blur coordinates:

[0085] d=(x0+3,y0+1),e=(x0+4,y0+2),f=(x0+5,y0+2);

[0086] Similar to S4.1, (x0+3,y0+1), (x0+4,y0+2), (x0+5,y0+2) are input coordinate points whose x0 coordinates are outside 3 and equal to 3, and whose y0 coordinates are outside 1 and include 1, and are weakly correlated with the pixel value of (x0,y0);

[0087] S5, determine whether it is out of bounds (taking x0 and y0 as an example), and correct its coordinate points:

[0088] If x0>src_w; x0=src_w;

[0089] If the x coordinate of the inverse input is greater than the input width, x0 takes src_w;

[0090] If y0>src_h; y0=src_h;

[0091] If the h coordinate of the inverse input is greater than the input height, y0 takes src_h;

[0092] S6, in the prior art, bilinear interpolation assigns weights to the four coordinates when calculating pixel values. Each weight represents the importance of the pixel value of each coordinate point. The larger the weight ratio, the closer the pixel value is to the output coordinate. However, in order to eliminate the aliasing of the output image, this paper needs to increase the weight of the image blur coordinates, so the image key coordinates and the image blur coordinates are assigned equal weights, in the hope that the image blur coordinates can play a key role in generating the image, thereby eliminating aliasing. In summary, the pixel point value of the output coordinate (x, y) is equal to the sum and average of the pixel point values ​​of the 6 coordinates selected by the input:

[0093] Dst(x,y)=(a+b+c+d+e+f) / 6.

[0094] This method uses the Simd instruction set to optimize the logic as follows:

[0095] The step S1 calculates the maximum number of output data width_cycs for a batch process.

[0096] 1) A register can store up to 512 bits of data, that is, 64 8-bit data, so the maximum number of output data that can be processed at one time width_cycs is 64.

[0097] 2) The register read bit format is only o(256bit) / q(128bit) / d(64bit) / d(32bit), so the number of output data that can be processed at one time width_cycs can only be 1, 2, 4, 8, 16, 32.

[0098] 3) The optimization core is to obtain the input data through the relational array through the gshfvb instruction in MXU3 to participate in the calculation. The gshufvb instruction obtains the data of the corresponding coordinate points of the input image through the lower 6 bits of each byte. The number that 6 bits can represent is 0-63, so the difference between the maximum and minimum values ​​of each batch of data in the relational array cannot be higher than 63. Therefore, when the input data is 8 bits, the calculation formula of width_cycs is:

[0099] Width_scale=(float)src_w / (float)dst_w;

[0100] Width_cycs=(int)64 / width_scale;

[0101] Relational Width_cycs Greater than or equal to 2 and less than 4 2 Greater than or equal to 4 and less than 8 4 Greater than or equal to 8 and less than 16 8 Greater than 16 and less than 32 16 Greater than 32 32

[0102] For ease of understanding, if src_w = 64, dst_w = 6, width_scale = 10.667, then:

[0103] Width_scale 10.667 dst coordinate in the x direction 0123456 Src in the x direction 0102132425364

[0104] When width_cycs is equal to 6, the maximum and minimum values ​​of the src coordinates stored in a batch are already greater than 63, so according to the above relationship, width_cycs is equal to 4, and 4 coordinate points are calculated at a time in a batch.

[0105] Get width_cycs through S3, and then save the coordinate correspondence into an array in advance according to the size of width_cycs, which can save a lot of calculation time. The X and Y coordinates are calculated as follows:

[0106]

[0107] Therefore, the corresponding relationship between the output and the input is stored in the relation array in advance.

[0108] According to step S6, the corresponding input data is obtained by using the relational array for parallel calculation, that is, a total of 6 groups of data are obtained, each group of data contains four input coordinate points, and the pixel values ​​of four output coordinate points are obtained. The above operation can be achieved using the gshufvb instruction in the MXU3 instruction set; then the basic addition FADDW and multiplication FMULW instructions in the MXU3 instruction set are used to obtain four output values ​​in parallel at one time, reducing redundant calculations and optimizing time efficiency.

[0109] The gshufvb instruction introduction and specific implementation process are as follows:

[0110]

[0111]

[0112] As a result, four output values ​​can be obtained through parallel calculations at one time, reducing redundant calculations and optimizing time efficiency.

[0113] The above method uses the correspondence between the output image and the input image, stores the relation array in the array in advance, and then obtains data in batches from the relation array and the input data for calculation through the gshufvb instruction. When the relation array stores 32 data, the time optimization efficiency is the highest, and the optimization efficiency exceeds 98%.

[0114] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the embodiments of the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method to optimize the jaggedness of bilinear interpolation and nearest neighbor interpolation, It is characterized in that The method utilizes a stepwise pixel acquisition method and includes the following steps: S1, get the scaling ratio in the width w direction, input image width src_w / output image width dst_w, located in the image coordinate system of width and height, the scaling ratio in the w direction is as follows: Width_scale=(float)src_w / (float)dst_w; S2, get the scaling ratio in the height h direction, input image height src_h / output image height dst_h, located in the image coordinate system of width and height, the scaling ratio in the h direction is as follows: Height_scale=(float)src_h / (float)dst_h; S3, inverting the input pixel coordinates through the output pixel coordinates, including: S3.

1. Calculate the wide x-coordinate point, where x is the output wide coordinate point and x0 is the reversed input wide coordinate point: x0 = (int)x * width_scale; S3.

2. Calculate the high y coordinate point, where y is the output high coordinate point and y0 is the high coordinate point in reverse order: y0 = (int)y * height_scale; S4, select 6 coordinate point values ​​to participate in the calculation. The selected coordinates are divided into image key coordinates and image fuzzy coordinates. The image key coordinate pixels obtain image key information, and the image fuzzy coordinates obtain the edge information of the pixel coordinate points. The number of image key coordinates and image fuzzy coordinates needs to be balanced and moderate. Therefore, three image key coordinates and three image fuzzy coordinates are selected, including: S4.1, image key coordinates: a=(x0,y0),b=(x0+1,y0),c=(x0+2,y0+1); (x0, y0) is the input coordinate point inferred from the output coordinate (x, y) according to the formula in step S3, (x0+1, y0) and (x0+2, y0+1) are input coordinate points whose x0 coordinate is within 3 and y0 coordinate is within 2 of (x0, y0), and are strongly correlated with the pixel value of (x0, y0); S4.2, image blur coordinates: d=(x0+3,y0+1),e=(x0+4,y0+2),f=(x0+5,y0+2); Similar to step S4.1, (x0+3,y0+1), (x0+4,y0+2), (x0+5,y0+2) are input coordinate points whose x0 coordinates are outside 3 and equal to 3, and whose y0 coordinates are outside 1 and include 1, and are weakly correlated with the pixel value of the coordinate (x0,y0); S5, determine whether it is out of bounds, and correct its coordinate point according to x0 and y0 in step S4: If x0>src_w; then x0=src_w; If the x coordinate of the inverse input is greater than the input width, x0 takes src_w; If y0>src_h; then y0=src_h; If the h coordinate of the inverse input is greater than the input height, y0 takes src_h; S6, the pixel value of the output coordinate (x, y) is derived from the pixel values ​​of the six coordinates in step S4, and the weights of the six pixel points are all set to 1, that is, the image key coordinates and the image blur coordinates are given equal weights, in the hope that the image blur coordinates can play a key role in generating the image, thereby eliminating aliasing; therefore, the pixel value of the output coordinate Dst (x, y) is obtained as follows: Dst(x,y)=(1*a+1*b+1*c+1*d+1*e+1*f) / 6; The pixel value of the output coordinate (x, y) is equal to the pixel value of the 6 coordinates obtained in step S4 multiplied by their respective weights 1 divided by the total number of coordinate points 6; The pixel value of the output coordinate (x, y) is equal to the average of the six pixel values ​​selected as input coordinates: Dst(x,y)=(a+b+c+d+e+f) / 6.

2. The method for optimizing bilinear interpolation and nearest neighbor interpolation aliasing according to claim 1, It is characterized in that The method is optimized by using the MUX3 instruction set, wherein the MUX3 is a set based on simd instructions, further: The step S1 includes: calculating the maximum number of output image coordinate points width_cycs that can be processed in one batch: 1) A register can store up to 512 bits of data, that is, 64 8-bit data, so the maximum number of output data that can be processed at one time width_cycs is 64; 2) The register read bit format is only o(256bit) / q(128bit) / d(64bit) / d(32bit), so the number of output data that can be processed at one time width_cycs can only be 1, 2, 4, 8, 16, 32; 3) The optimization is to obtain the input data through the relational array through the gshufvb instruction in the MXU3 instruction set to participate in the calculation. The gshufvb instruction obtains the data of the corresponding coordinate points of the input image through the lower 6 bits of each byte. The number that 6 bits can represent is 0-63, so the difference between the maximum and minimum values ​​of each batch of data in the relational array cannot be higher than 63; therefore, when the input data is 8 bits, the calculation formula of width_cycs is: Width scaling ratio: width_scale = (float)src_w / (float)dst_w;) width_cycs=(int)64 / width_scale; The mapping relationship is as follows, width_cycs has nothing to do with the scaling in the h direction: The size of width_cycs is obtained through step S3, and then according to the size of width_cycs, the coordinate correspondence is saved in the array in advance, which can save a lot of calculation time. The X and Y coordinates are calculated as follows: Therefore, the corresponding relationship between output and input is stored in the relation array in advance; According to step S6, the corresponding input data is obtained by using the relational array for parallel calculation, that is, a total of 6 groups of data are obtained, each group of data contains four input coordinate points, and the pixel values ​​of four output coordinate points are obtained. The above operation can be achieved using the gshufvb instruction in the MXU3 instruction set; then the basic addition FADDW and multiplication FMULW instructions in the MXU3 instruction set are used to obtain four output values ​​in parallel at one time, reducing redundant calculations and optimizing time efficiency.

3. The method for optimizing bilinear interpolation and nearest neighbor interpolation aliasing according to claim 2, It is characterized in that In the step S1, Assume src_w = 64, dst_w = 6, width_scale = 10.667, then: When width_cycs is equal to 6, the maximum and minimum values ​​of the src coordinates stored in a batch are already greater than 63, so according to the above relationship, width_cycs is equal to 4, and 4 coordinate points are calculated at a time in a batch.

4. The method for optimizing bilinear interpolation and nearest neighbor interpolation aliasing according to claim 2, It is characterized in that The gshufvb instruction and specific implementation process are as follows:

5. A method for optimizing bilinear interpolation and nearest neighbor interpolation aliasing according to claim 4, It is characterized in that The method uses the correspondence between the output image and the input image, stores the relation array in advance in the array, and then obtains data in batches from the relation array and the input data for calculation through the gshufvb instruction. When the relation array stores 32 data, the time optimization efficiency is maximum, and the optimization efficiency exceeds 98%.