0
0
Computer Visionml~10 mins

What computer vision encompasses - 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]('image.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
Using imwrite which saves images
2fill in blank
medium

Complete the code to convert an image to grayscale.

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

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

Computer Vision
edges = cv2.Canny(image, [1], 100)
Drag options to blanks, or click blank then click option'
A50
B'50'
Cimage
DNone
Attempts:
3 left
💡 Hint
Common Mistakes
Passing threshold as a string
Passing None or image instead of a number
4fill in blank
hard

Fill both blanks to create a dictionary of image sizes for images with width greater than 100.

Computer Vision
sizes = {img: (img.shape[[1]], img.shape[[2]]) for img in images if img.shape[1] > 100}
Drag options to blanks, or click blank then click option'
A0
B1
C2
D3
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping height and width indices
Using invalid indices like 3
5fill in blank
hard

Fill all three blanks to filter images by height and create a dictionary of their shapes.

Computer Vision
filtered = {img: img.shape for img in images if img.shape[[1]] [2] [3]
Drag options to blanks, or click blank then click option'
A0
B>
C200
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using width index 1 instead of height 0
Using '<' instead of '>'
Using wrong threshold value