0
0
Computer Visionml~10 mins

Feature extraction approach 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 extract features from an image using a simple method.

Computer Vision
import cv2
image = cv2.imread('image.jpg', 0)
features = cv2.Canny(image, [1], 150)
print(features.shape)
Drag options to blanks, or click blank then click option'
A50
B100
C200
D300
Attempts:
3 left
💡 Hint
Common Mistakes
Using a threshold too high or too low can miss edges or detect too many.
2fill in blank
medium

Complete the code to compute Histogram of Oriented Gradients (HOG) features from an image.

Computer Vision
from skimage.feature import hog
from skimage import data, exposure
image = data.astronaut()
features, hog_image = hog(image, pixels_per_cell=(8, 8), cells_per_block=(2, 2), visualize=True, [1]=True)
print(features.shape)
Drag options to blanks, or click blank then click option'
Amultichannel
Bnormalize
Cblock_norm
Dtransform_sqrt
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to set multichannel=True causes errors or wrong features.
3fill in blank
hard

Fix the error in the code to extract SIFT features from an image.

Computer Vision
import cv2
image = cv2.imread('image.jpg', 0)
sift = cv2.SIFT_create()
keypoints, descriptors = sift.[1](image)
print(len(keypoints))
Drag options to blanks, or click blank then click option'
AdetectAndCompute
Bdetect
Ccompute
DdetectAndDescribe
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'detect' or 'compute' alone causes errors or incomplete results.
4fill in blank
hard

Fill both blanks to create a dictionary of feature descriptors for each keypoint.

Computer Vision
features_dict = [1](kp.pt: desc for kp, desc in zip(keypoints, [2]))
print(len(features_dict))
Drag options to blanks, or click blank then click option'
Adict
Bdescriptors
Clist
Dkeypoints
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'list' instead of 'dict' or wrong variable names.
5fill in blank
hard

Fill all three blanks to filter features with descriptor length greater than 100.

Computer Vision
filtered_features = {kp: desc for kp, desc in features_dict.items() if len(desc) [1] [2]
print(len(filtered_features))

threshold = [3]
Drag options to blanks, or click blank then click option'
A>
B100
C<
D50
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>' or wrong threshold values.