开发者

Numpy image - rotate matrix 270 degrees

开发者 https://www.devze.com 2022-12-23 08:46 出处:网络
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:

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?


You can tell rot90 to rotate several times, this should work:

rotated = numpy.rot90(orignumpyarray,3)


rotated_array =numpy.rot90(orignumpyarray,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.

0

精彩评论

暂无评论...
验证码 换一张
取 消