0
0
Computer Visionml~10 mins

CV project workflow 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 images from a folder using OpenCV.

Computer Vision
import cv2
image = cv2.imread([1])
print(image.shape)
Drag options to blanks, or click blank then click option'
Afolder_path
Bimage.jpg
Ccv2.imread
D'image.jpg'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the filename
Passing a variable name without defining it
2fill in blank
medium

Complete the code to resize an image to 100x100 pixels.

Computer Vision
resized_image = cv2.resize(image, [1])
print(resized_image.shape)
Drag options to blanks, or click blank then click option'
A(100)
B(100, 100)
C[100, 100]
D100, 100
Attempts:
3 left
💡 Hint
Common Mistakes
Using a single integer instead of a tuple
Using a list instead of a tuple
3fill in blank
hard

Fix the error in the code to convert an image to grayscale.

Computer Vision
gray_image = cv2.cvtColor(image, [1])
print(gray_image.shape)
Drag options to blanks, or click blank then click option'
Acv2.COLOR_BGR2GRAY
Bcv2.COLOR_BGR2RGB
Ccv2.COLOR_RGB2GRAY
Dcv2.COLOR_GRAY2BGR
Attempts:
3 left
💡 Hint
Common Mistakes
Using RGB instead of BGR conversion code
Using grayscale to BGR conversion code
4fill in blank
hard

Fill both blanks to create a dictionary of image filenames and their sizes (width, height).

Computer Vision
image_sizes = {filename: (image.shape[[1]], image.shape[[2]]) for filename, image in images.items()}
Drag options to blanks, or click blank then click option'
A1
B0
C2
D3
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping width and height indexes
Using channel index 2 instead of width or height
5fill in blank
hard

Fill all three blanks to filter images with width greater than 200 and create a new dictionary with filename and width.

Computer Vision
filtered_images = {filename: image.shape[[1]] for filename, image in images.items() if image.shape[[2]] [3] 200}
Drag options to blanks, or click blank then click option'
A0
B1
C>
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using height index 0 instead of width
Using less than operator instead of greater than