Numpy 图像 - 旋转矩阵 270 度
我有一个代表灰度图像的 Numpy 2d 数组,我需要将其旋转 270 度。这里可能有点厚,但我能找到的两种方法似乎很……循环:
rotated = numpy.rot90(numpy.rot90(numpy.rot90(orignumpyarray)))
rotated = numpy.fliplr(numpy.flipud(numpy.rot90(orignumpyarray)))
我认为必须有一种更好的方法可以在一次操作中完成此操作。基本上是一个 rot270() 函数?有什么想法吗?
I've got a Numpy 2d array that represents a grey-scale image and I need to rotate it 270 degrees. Might be being a bit thick here but the two ways I can find to do this seem quite... circulous:
rotated = numpy.rot90(numpy.rot90(numpy.rot90(orignumpyarray)))
rotated = numpy.fliplr(numpy.flipud(numpy.rot90(orignumpyarray)))
I'm thinking there must be a better way to do this in one operation. Basically a rot270() function? Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以将 rot90 告诉 旋转几次,这应该有效:
You can tell
rot90
to rotate several times, this should work:函数解释:
numpy.rot90(a,b)
a = 要旋转的数组
b = 您想要将其旋转 90 度多少次。在这里你想要 270° 所以
90° * 3 = 270° 这就是为什么这里 b = 3。
Explanation of the function:
numpy.rot90(a,b)
a = Array which you want to rotate
b = How many times you want to rotate it by 90 degrees. For here you want 270° so
90° * 3 = 270° that is why b = 3 here.