Fast rotation of flat images

xiaoxiao2021-03-06  43

Original problem: http://community.9cbs.net/expert/topic/3757/3757859.xml? Temp = 5.727786e-02 Rotate an angle alpha in a point, multiplied by a matrix, but for a whole In the picture, if each point is multiplied by a matrix, the speed is too slow, is there a quick algorithm to rotate the entire picture? Basic knowledge rotates an image. If it is calculated from the pixel point to the target image from the original map, it will cause the empty hole on the target picture to calculate the pixel point on the rotating picture. In the position of the original map, since the rotation does not guarantee a complete corresponding corresponding to the pixel position on the target picture, it is generally necessary to perform a difference in smooth processing, and a smooth processing inevitably involves multiplication operation. Or double linear or triple difference calculation. However, in the case of high quality requirements, there is a way to accelerate the optimization process for speed requirements. We know that there is a two-dimensional bitmap picture, if you want to rotate it, the basic algorithm is: x1 , Y1 corresponds to the formula after the rotation point: X0 = x1 * COSA Y1 * SINA NUM1; Y0 = -x1 * sina Y1 * COSA NUM2; then the point on the horizontal line (x1 DX), Y1 corresponds to points X0 ', Y0' is X0 '= X0 DX * COSA Y0' = Y0 - DX * SINA For DX fixed, COSA, Sina is also value this, so you can be positioned behind the horizontal line. Sequential increment

Similarly to the point X0 '', Y0 '' on the vertical line, the point X0 '', Y0 '' has similar formula X0 '' = x0 DY * sina Y0 '= Y0 DY * COSA, the same DY and SINA, COSA It is also a fixed value with the above formula. We can quickly find a horizontal or vertical straight line in the target picture, in the original position, the new location can be determined by simple addition, no longer need to multiply calculated.

转载请注明原文地址:https://www.9cbs.com/read-63641.html

New Post(0)