0
0
Computer Visionml~10 mins

Geometric transforms (rotate, flip, crop) in Computer Vision - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to rotate the image by 90 degrees clockwise using OpenCV.

Computer Vision
rotated_image = cv2.rotate(image, [1])
Drag options to blanks, or click blank then click option'
Acv2.ROTATE_90_COUNTERCLOCKWISE
Bcv2.ROTATE_180
Ccv2.ROTATE_90_CLOCKWISE
Dcv2.FLIP_HORIZONTAL
Attempts:
3 left
💡 Hint
Common Mistakes
Using the counterclockwise rotation constant instead.
Using flip constants instead of rotate.
2fill in blank
medium

Complete the code to flip the image vertically using OpenCV.

Computer Vision
flipped_image = cv2.flip(image, [1])
Drag options to blanks, or click blank then click option'
A2
B1
C-1
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using 1 which flips horizontally instead.
Using -1 which flips both axes.
3fill in blank
hard

Fix the error in the code to crop the image correctly using NumPy slicing.

Computer Vision
cropped_image = image[[1]:[1]+100, 50:150]
Drag options to blanks, or click blank then click option'
A0
B50
C100
D150
Attempts:
3 left
💡 Hint
Common Mistakes
Starting crop at row 100 which may be outside image bounds.
Using column indices for row slicing.
4fill in blank
hard

Fill both blanks to create a horizontal flip and then crop the center 100x100 pixels of the image.

Computer Vision
flipped = cv2.flip(image, [1])
cropped = flipped[[2]:[2]+100, 100:200]
Drag options to blanks, or click blank then click option'
A1
B0
C50
D100
Attempts:
3 left
💡 Hint
Common Mistakes
Using vertical flip code 0 instead of horizontal.
Starting crop at 100 which is too low for center crop.
5fill in blank
hard

Fill all three blanks to rotate the image 180 degrees, flip vertically, and then crop the top-left 50x50 pixels.

Computer Vision
rotated = cv2.rotate(image, [1])
flipped = cv2.flip(rotated, [2])
cropped = flipped[[3]:[3]+50, 0:50]
Drag options to blanks, or click blank then click option'
Acv2.ROTATE_180
B0
Dcv2.ROTATE_90_CLOCKWISE
Attempts:
3 left
💡 Hint
Common Mistakes
Using 90 degree rotation instead of 180.
Using horizontal flip code 1 instead of vertical.
Starting crop at wrong row index.