0
0
Computer Visionml~20 mins

Edge detection (Canny) in Computer Vision - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Canny Edge Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of Canny edge detection with different thresholds

Given the following Python code using OpenCV to apply Canny edge detection, what will be the shape of the output image?

Computer Vision
import cv2
import numpy as np

image = np.zeros((100, 100), dtype=np.uint8)
cv2.rectangle(image, (25, 25), (75, 75), 255, -1)
edges = cv2.Canny(image, 50, 150)
print(edges.shape)
A(98, 98)
B(50, 50)
C(102, 102)
D(100, 100)
Attempts:
2 left
💡 Hint

Remember that Canny edge detection returns an image of the same size as the input.

Model Choice
intermediate
2:00remaining
Choosing parameters for Canny edge detection

Which pair of threshold values is most likely to detect edges clearly without too much noise in a typical grayscale image?

ALow threshold = 100, High threshold = 110
BLow threshold = 50, High threshold = 150
CLow threshold = 10, High threshold = 200
DLow threshold = 200, High threshold = 250
Attempts:
2 left
💡 Hint

The high threshold should be significantly higher than the low threshold to filter noise.

🔧 Debug
advanced
2:00remaining
Why does this Canny edge detection code raise an error?

Consider this code snippet:

import cv2
image = cv2.imread('image.jpg')
edges = cv2.Canny(image, 100, 200)

It raises an error. What is the cause?

AThe image is not converted to grayscale before applying Canny
BThe threshold values are invalid (should be between 0 and 1)
CThe image path is incorrect
DCanny requires a color image, but a grayscale image was given
Attempts:
2 left
💡 Hint

Canny expects a single channel image.

Metrics
advanced
2:00remaining
Evaluating edge detection quality

Which metric is best suited to quantitatively compare the quality of edges detected by Canny against a ground truth edge map?

AMean Squared Error (MSE)
BAccuracy
CIntersection over Union (IoU)
DRoot Mean Squared Error (RMSE)
Attempts:
2 left
💡 Hint

Think about how well the detected edges overlap with the true edges.

🧠 Conceptual
expert
2:00remaining
Understanding the role of Gaussian smoothing in Canny edge detection

Why does the Canny edge detection algorithm apply Gaussian smoothing before finding edges?

ATo reduce noise and avoid detecting false edges
BTo increase the contrast of edges
CTo sharpen the image details
DTo convert the image to grayscale
Attempts:
2 left
💡 Hint

Think about what noise does to edge detection.