Challenge - 5 Problems
Edge Detection Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of Sobel filter on a simple image
What is the output array after applying the Sobel filter on the given 3x3 image using scipy.ndimage.sobel with axis=0?
SciPy
import numpy as np from scipy import ndimage image = np.array([[10, 10, 10], [20, 20, 20], [30, 30, 30]]) sobel_vertical = ndimage.sobel(image, axis=0) print(sobel_vertical)
Attempts:
2 left
💡 Hint
Think about how the Sobel filter calculates the gradient along the vertical axis.
✗ Incorrect
The Sobel filter computes the gradient by subtracting pixel values above and below. The output shows positive values where intensity increases downward and negative where it decreases.
❓ data_output
intermediate2:00remaining
Number of edges detected by Laplace filter
After applying the Laplace filter on the given 5x5 image, how many pixels have a non-zero value indicating edges?
SciPy
import numpy as np from scipy import ndimage image = np.array([ [10, 10, 10, 10, 10], [10, 50, 50, 50, 10], [10, 50, 100, 50, 10], [10, 50, 50, 50, 10], [10, 10, 10, 10, 10] ]) laplace = ndimage.laplace(image) non_zero_count = np.count_nonzero(laplace) print(non_zero_count)
Attempts:
2 left
💡 Hint
Edges are where the Laplace output is not zero, usually around intensity changes.
✗ Incorrect
The Laplace filter highlights regions with rapid intensity changes. Counting non-zero pixels gives the number of detected edges.
🔧 Debug
advanced2:00remaining
Identify the error in Sobel filter application
What error will this code raise when applying the Sobel filter incorrectly?
SciPy
import numpy as np from scipy import ndimage image = np.array([[1, 2], [3, 4]]) sobel = ndimage.sobel(image, axis=2) print(sobel)
Attempts:
2 left
💡 Hint
Check the axis parameter against the image array dimensions.
✗ Incorrect
The image is 2D, so axis=2 is invalid and causes an IndexError.
❓ visualization
advanced2:00remaining
Visual difference between Sobel and Laplace filters
Which option best describes the visual difference when applying Sobel and Laplace filters on the same image?
Attempts:
2 left
💡 Hint
Think about directional vs. non-directional edge detection.
✗ Incorrect
Sobel calculates gradient in a specific direction, while Laplace detects edges by second derivatives and zero-crossings.
🚀 Application
expert3:00remaining
Combining Sobel and Laplace for edge enhancement
Given an image, which code snippet correctly combines Sobel filters on both axes and the Laplace filter to create an enhanced edge image?
Attempts:
2 left
💡 Hint
Combine gradients from both directions using Pythagorean theorem before adding Laplace.
✗ Incorrect
The combined magnitude of Sobel x and y gradients gives edge strength; adding Laplace enhances edges further.