0
0
Computer Visionml~10 mins

CV applications (autonomous driving, medical, retail) 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 load an image using OpenCV.

Computer Vision
import cv2
image = cv2.[1]('road.jpg')
Drag options to blanks, or click blank then click option'
Aresize
Bimshow
Cimwrite
Dimread
Attempts:
3 left
💡 Hint
Common Mistakes
Using imshow instead of imread will cause an error because imshow displays images, not loads them.
Using imwrite tries to save an image, not load it.
2fill in blank
medium

Complete the code to convert a color image to grayscale.

Computer Vision
gray_image = cv2.cvtColor(image, [1])
Drag options to blanks, or click blank then click option'
Acv2.COLOR_BGR2GRAY
Bcv2.COLOR_RGB2BGR
Ccv2.COLOR_GRAY2BGR
Dcv2.COLOR_BGR2RGB
Attempts:
3 left
💡 Hint
Common Mistakes
Using COLOR_BGR2RGB changes color format but does not convert to grayscale.
Using COLOR_GRAY2BGR converts grayscale to color, which is the opposite.
3fill in blank
hard

Fix the error in the code to detect edges using Canny edge detector.

Computer Vision
edges = cv2.Canny(image, [1], 150)
Drag options to blanks, or click blank then click option'
A100
B'100'
CNone
Dimage
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a string instead of a number causes a type error.
Passing None will cause the function to fail.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps image names to their sizes if width {{BLANK_1}} 500 and height {{BLANK_2}} 500.

Computer Vision
sizes = {name: (img.shape[1], img.shape[0]) for name, img in images.items() if img.shape[1] [1] 500 and img.shape[0] [2] 500}
Drag options to blanks, or click blank then click option'
A>
B<
C>=
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong comparison operators reverses the filter logic.
Using >= or <= changes the condition boundaries.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps patient IDs to their diagnosis if confidence {{BLANK_1}} 0.8 and diagnosis {{BLANK_2}} 'positive' and patient ID {{BLANK_3}} starts with 'P'.

Computer Vision
results = {pid: diag for pid, (diag, conf) in data.items() if conf [1] 0.8 and diag [2] 'positive' and pid.[3]('P')}
Drag options to blanks, or click blank then click option'
A>=
B==
Cstartswith
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '!=' instead of '==' for diagnosis causes wrong filtering.
Using '>' instead of '>=' excludes confidence exactly 0.8.
Using a wrong string method for patient ID causes errors.