Complete the code to rotate the image by 90 degrees clockwise using OpenCV.
rotated_image = cv2.rotate(image, [1])To rotate an image 90 degrees clockwise in OpenCV, use cv2.ROTATE_90_CLOCKWISE as the flag.
Complete the code to flip the image vertically using OpenCV.
flipped_image = cv2.flip(image, [1])In OpenCV, flipping with 0 flips the image vertically (upside down).
Fix the error in the code to crop the image correctly using NumPy slicing.
cropped_image = image[[1]:[1]+100, 50:150]
To crop starting from the top, use 0 as the starting row index.
Fill both blanks to create a horizontal flip and then crop the center 100x100 pixels of the image.
flipped = cv2.flip(image, [1]) cropped = flipped[[2]:[2]+100, 100:200]
Flip code 1 flips horizontally. Cropping starts at row 50 to get center 100 pixels vertically.
Fill all three blanks to rotate the image 180 degrees, flip vertically, and then crop the top-left 50x50 pixels.
rotated = cv2.rotate(image, [1]) flipped = cv2.flip(rotated, [2]) cropped = flipped[[3]:[3]+50, 0:50]
Rotate 180 degrees uses cv2.ROTATE_180. Flip vertically uses code 0. Crop starts at row 0 for top-left corner.