Python学习,^ Aq,F&yC'g+T9\ 旋转有一个绕什么转的问题。 `;N2@GT.A-q8tf {0 Python学习)I.i0U8yZfv4Kl O|我们先来看最简单的,绕第一个像素转,则旋转的情况会像这样:Python学习/Olr-x&]A Python学习#~f(DV:zN6b^$]
令旋转前有 T_6uat#z*K]+u0 Python学习nx*[(T9y,^8Gn
YP6s/HZ"p2\X,N2W0旋转a角度后有 v*_IB/y$qI02R8Q-Kov5_:x-AK:fb_0
I8|LOb?xY ~a0以矩阵形式表示为 .~-qj:q2hob$p0w'Yr7{%vH W0
编写程序:Python学习!?y*M/X v/H0CZ C m^a3LVp!G"R0import cv $F0OLI nL*`0OQ@Q}S"x(C)\0import math WVg+i9i,K0cwp2Ch0A.~mC0def SRotate(image,angle):Python学习L u^'t^5_X7rf#|0^} Python学习1g"_R5Ss+bY$fsize = (image.width,image.height)Python学习%l@i)Gvv ;q#`5BY|X \^0iSRotate = cv.CreateImage(size,image.depth,image.nChannels)Python学习*e"~.P*t$x#q Python学习,Q9].LjD-l/nO6S.NGfor i in range(image.height): UApp%z!LF0(lJ]s Z1W"r[0for j in range(image.width): }@pQ4U0`p\0q/e0anglePi = angle*math.pi/180.0 (@)E*D"P}2Q~0 Python学习#xF2?X"C0k$ex = int(math.cos(anglePi)*i+math.sin(anglePi)*j)Python学习\&["[k gb[/G y['[&r#|7z0~ E*d0y = int(-math.sin(anglePi)*i+math.cos(anglePi)*j)Python学习+}3R_ Af1GX Python学习Q f[ J*J_$]W3Jrif x>-1 and x-1 and y (责任编辑:JavaVideo) |




