Algorithm to rotate an image 90 degrees in place? (No extra memory)

前端 未结 9 924
囚心锁ツ
囚心锁ツ 2020-11-29 06:26

In an embedded C app, I have a large image that I\'d like to rotate by 90 degrees. Currently I use the well-known simple algorithm to do this. However, this algorithm requi

9条回答
  •  情书的邮戳
    2020-11-29 07:02

    This might be too vague, and not be what you're looking for, but I'm gonna post anyway.

    If you consider an image to be a 2d array of pixels, you only need to reverse the order of either the top-level or nested array, depending on whether you want horizontal or vertical flipping..

    So you would either loop through each pixel column (0->columns/2), and swap them (so you only need temp memory for 1 pixel, not the whole picture), or loop through rows for horizontal flipping.. Does that make sense? Will elaborate / write code if not..

提交回复
热议问题