Numpy image - rotate matrix 270 degrees

一曲冷凌霜 提交于 2019-11-27 23:09: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:

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?


回答1:


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

rotated = numpy.rot90(orignumpyarray,3)


来源:https://stackoverflow.com/questions/2461303/numpy-image-rotate-matrix-270-degrees

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!