0
0
Computer Visionml~10 mins

Cropping images 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 crop the image using slicing.

Computer Vision
cropped_img = img[[1]:100, 50:150]
Drag options to blanks, or click blank then click option'
A50
B0
C20
D100
Attempts:
3 left
💡 Hint
Common Mistakes
Using column index first instead of row index.
Starting slice at 0 which crops from the top instead of desired position.
2fill in blank
medium

Complete the code to crop the image to a square of size 50x50 pixels starting at (30, 40).

Computer Vision
cropped_img = img[[1]:[1]+50, 40:90]
Drag options to blanks, or click blank then click option'
A30
B40
C50
D20
Attempts:
3 left
💡 Hint
Common Mistakes
Using the column index as the first slice index.
Not adding 50 to the start index for the end index.
3fill in blank
hard

Fix the error in the code to correctly crop the image region from (10, 20) to (60, 70).

Computer Vision
cropped_img = img[10:[1], 20:70]
Drag options to blanks, or click blank then click option'
A60
B70
C50
D80
Attempts:
3 left
💡 Hint
Common Mistakes
Using 70 as the end row index which is beyond the desired crop.
Using 50 which crops less than intended.
4fill in blank
hard

Fill both blanks to crop a 40x40 pixel square starting at (15, 25).

Computer Vision
cropped_img = img[[1]:[2], 25:65]
Drag options to blanks, or click blank then click option'
A15
B55
C65
D40
Attempts:
3 left
💡 Hint
Common Mistakes
Using 65 as the end row index which is too large.
Using 40 as the start index instead of 15.
5fill in blank
hard

Fill all three blanks to crop the image from (10, 20) to (60, 70) and convert to grayscale.

Computer Vision
cropped_img = img[[1]:[2], [3]:70]
gray_img = cv2.cvtColor(cropped_img, cv2.COLOR_BGR2GRAY)
Drag options to blanks, or click blank then click option'
A10
B60
C20
D50
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up row and column indices.
Not converting to grayscale after cropping.