Untitled
unknown
python
21 days ago
967 B
1
Indexable
Never
def rotate_image(image, rotation): n = len(image) if rotation == 90: return [[image[n - j - 1][i] for j in range(n)] for i in range(n)] elif rotation == 180: return [[image[n - i - 1][n - j - 1] for j in range(n)] for i in range(n)] elif rotation == 270: return [[image[j][n - i - 1] for j in range(n)] for i in range(n)] else: return image def flip_vertical(image): return image[::-1] def flip_horizontal(image): return [row[::-1] for row in image] # Step 1: Rotate the image based on the 'rotation' parameter image = rotate_image(image, rotation) # Step 2: Flip the image vertically if 'vertical_flip' is 1 if vertical_flip == 1: image = flip_vertical(image) # Step 3: Flip the image horizontally if 'horizontal_flip' is 1 if horizontal_flip == 1: image = flip_horizontal(image) return image
Leave a Comment