Rotating a 2D pixel array by 90 degrees

前端 未结 4 1823
予麋鹿
予麋鹿 2020-12-05 20:59

I have an array of pixel data for an image. The image I am getting is already rotated to 270 degrees. So I am trying to rotate it again by 90 degrees to have the correct ima

4条回答
  •  粉色の甜心
    2020-12-05 21:29

    This can be done without using any extra space, so called In-place matrix transposition (not exact the same). Remember to do some mirroring after the transposition.

    1. If the image is square

      enter image description here

    2. If the image is not square

      • For non-square matrices, the algorithms are more complicated. Many of the algorithms prior to 1980 could be described as "follow-the-cycles" algorithms. That is, they loop over the cycles, moving the data from one location to the next in the cycle. In pseudocode form:

      enter image description here

提交回复
热议问题