0
0
Computer Visionml~20 mins

Image gradients (Sobel, Laplacian) in Computer Vision - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Image Gradient Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of Sobel filter on a simple image
What is the output array after applying the Sobel filter on the given 3x3 grayscale image using OpenCV's Sobel function with dx=1, dy=0, and kernel size 3?
Computer Vision
import cv2
import numpy as np

image = np.array([[10, 10, 10],
                  [10, 20, 10],
                  [10, 10, 10]], dtype=np.uint8)

sobelx = cv2.Sobel(image, cv2.CV_64F, 1, 0, ksize=3)
output = sobelx.astype(int)
print(output)
A
[[  0 -10   0]
 [  0   0   0]
 [  0  10   0]]
B
[[  0  10   0]
 [  0   0   0]
 [  0 -10   0]]
C
[[  0   0   0]
 [  0   0   0]
 [  0   0   0]]
D
[[  0   0   0]
 [ 10   0 -10]
 [  0   0   0]]
Attempts:
2 left
💡 Hint
Sobel with dx=1 detects horizontal edges by calculating differences along the x-axis.
🧠 Conceptual
intermediate
1:30remaining
Understanding Laplacian filter effect
Which statement best describes the effect of applying a Laplacian filter to a grayscale image?
AIt detects edges by calculating the first derivative only in the horizontal direction.
BIt smooths the image by averaging neighboring pixels to reduce noise.
CIt detects edges by calculating the second derivative, highlighting regions of rapid intensity change.
DIt converts the image to binary by thresholding pixel values.
Attempts:
2 left
💡 Hint
Think about what the second derivative tells us about intensity changes.
Hyperparameter
advanced
1:30remaining
Choosing kernel size for Sobel filter
What is the effect of increasing the kernel size (ksize) parameter in OpenCV's Sobel function from 3 to 7?
AIt decreases the smoothing effect, making the filter more sensitive to noise and fine details.
BIt increases the smoothing effect, resulting in detecting broader edges but less noise sensitivity.
CIt changes the filter to detect vertical edges instead of horizontal edges.
DIt converts the Sobel filter into a Laplacian filter automatically.
Attempts:
2 left
💡 Hint
Larger kernels average over more pixels.
🔧 Debug
advanced
2:00remaining
Identifying error in Laplacian filter code
What error will this code produce when applying the Laplacian filter, and why? import cv2 import numpy as np image = np.array([[1,2],[3,4]], dtype=np.uint8) laplacian = cv2.Laplacian(image, cv2.CV_8U) print(laplacian)
Computer Vision
import cv2
import numpy as np

image = np.array([[1,2],[3,4]], dtype=np.uint8)
laplacian = cv2.Laplacian(image, cv2.CV_8U)
print(laplacian)
AThe output will be incorrect due to overflow because CV_8U cannot represent negative values from the Laplacian.
BThe code will raise a SyntaxError because of missing parentheses.
CThe code will raise a TypeError because image is not a float array.
DThe output will be a zero matrix because the image is too small.
Attempts:
2 left
💡 Hint
Laplacian can produce negative values; unsigned types cannot represent them.
Model Choice
expert
2:30remaining
Best gradient method for detecting fine edges in noisy images
You want to detect fine edges in a noisy grayscale image. Which gradient method and parameter choice is best to maximize edge detection while minimizing noise?
AUse Laplacian of Gaussian (LoG) filter which combines smoothing and second derivative.
BUse Laplacian filter directly on the noisy image without smoothing.
CUse Sobel filter with kernel size 7 without any smoothing.
DUse Sobel filter with kernel size 3 and apply Gaussian blur before filtering.
Attempts:
2 left
💡 Hint
Consider methods that combine smoothing and edge detection.