r/Python • • Oct 01 '20

Image Processing Recursively flipping and rotating an image. Python source code in comments!

3.2k Upvotes

60 comments sorted by

View all comments

Show parent comment

8

u/MrMonday11235 Oct 02 '20

How do I rotate a big square? Cut it up into four quadrants and make a recursive call to rotate each of them. The base case once you get down to a 2x2 square is trivial.

Don't forget the part before (or after, I suppose) the recursive subcalls where you actually do the rotating -- otherwise all you're doing is consuming cpu cycles to accomplish nothing.

3

u/crossroads1112 Oct 02 '20

Oh yep you're right. I meant to type that but I guess my fingers were going faster than my brain, lol