Challenge - 5 Problems
Edge Detection Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediateOutput of Sobel filter on a simple 3x3 image
What is the output array after applying the Sobel filter in the x-direction on the following 3x3 grayscale image?
[[10, 10, 10], [20, 20, 20], [30, 30, 30]]
Signal Processing
import numpy as np from scipy.ndimage import sobel image = np.array([[10, 10, 10], [20, 20, 20], [30, 30, 30]]) sobel_x = sobel(image, axis=1, mode='constant') print(sobel_x)
Attempts:
2 left
💡 Hint
Sobel in x-direction (axis=1) detects vertical edges by looking at changes horizontally along rows. Each row is constant, so zero output.
✗ Incorrect
The Sobel filter in x-direction calculates differences between neighboring columns. Since all columns are identical, there are no horizontal changes, resulting in zero everywhere.
❓ data_output
intermediateNumber of edges detected by Laplacian filter
Given a 5x5 image with a single white square in the center on a black background, how many non-zero pixels does the Laplacian filter detect as edges?
Signal Processing
import numpy as np from scipy.ndimage import laplace image = np.zeros((5,5)) image[2,2] = 255 lap = laplace(image) non_zero_count = np.count_nonzero(lap) print(non_zero_count)
Attempts:
2 left
💡 Hint
Laplacian highlights pixels where intensity changes sharply, including neighbors of the white pixel.
✗ Incorrect
The Laplacian filter detects edges by highlighting pixels where intensity changes. The single white pixel causes its four direct neighbors and itself to have non-zero Laplacian values, resulting in 5 non-zero pixels.
🔧 Debug
advancedIdentify the error in Sobel edge detection code
What error will this code raise when applying Sobel filter to an image?
import numpy as np from scipy.ndimage import sobel image = np.array([[1,2],[3,4]]) sobel_x = sobel(image, axis=2)
Signal Processing
import numpy as np from scipy.ndimage import sobel image = np.array([[1,2],[3,4]]) sobel_x = sobel(image, axis=2)
Attempts:
2 left
💡 Hint
Check the axis parameter against the image array dimensions.
✗ Incorrect
The image is 2D, so valid axis values are 0 or 1. Using axis=2 causes an IndexError because axis 2 does not exist.
❓ visualization
advancedVisual difference between Sobel and Laplacian edges
Which option best describes the visual difference between Sobel and Laplacian edge detection results on a grayscale image?
Attempts:
2 left
💡 Hint
Think about how Sobel uses gradients and Laplacian uses second derivatives.
✗ Incorrect
Sobel filter calculates gradient in specific directions, so edges have orientation. Laplacian uses second derivative and highlights edges regardless of direction.
🚀 Application
expertChoosing edge detection method for noisy images
You have a noisy grayscale image and want to detect edges robustly. Which method is best to reduce noise impact while detecting edges?
Attempts:
2 left
💡 Hint
Consider combining smoothing and edge detection in one step.
✗ Incorrect
Laplacian of Gaussian first smooths the image to reduce noise, then applies Laplacian to detect edges, making it robust for noisy images.
