[英]Numpy image - rotate matrix 270 degrees
I've got a Numpy 2d array that represents a grey-scale image and I need to rotate it 270 degrees.我有一个代表灰度图像的 Numpy 2d 数组,我需要将它旋转 270 度。 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?
基本上是一个 rot270() 函数? Any ideas?
有任何想法吗?
你可以告诉rot90
旋转几次,这应该有效:
rotated = numpy.rot90(orignumpyarray,3)
rotated_array =numpy.rot90(orignumpyarray,3)
Explanation of the function:功能说明:
numpy.rot90(a,b) numpy.rot90(a,b)
a = Array which you want to rotate a =要旋转的数组
b = How many times you want to rotate it by 90 degrees. b =您想要将其旋转 90 度的次数。 For here you want 270° so 90° * 3 = 270° that is why b = 3 here.
在这里你想要 270° 所以 90° * 3 = 270° 这就是为什么这里 b = 3。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.