0
0
SciPydata~10 mins

Sobel and Laplace edge detection in SciPy - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the Sobel filter from scipy.ndimage.

SciPy
from scipy.ndimage import [1]
Drag options to blanks, or click blank then click option'
Alaplace
Bsobel
Cgaussian_filter
Dmedian_filter
Attempts:
3 left
💡 Hint
Common Mistakes
Importing laplace instead of sobel.
Using gaussian_filter which is for smoothing, not edge detection.
2fill in blank
medium

Complete the code to apply the Sobel filter on the image array along the x-axis.

SciPy
edge_x = sobel(image, axis=[1])
Drag options to blanks, or click blank then click option'
A0
B-1
C1
D2
Attempts:
3 left
💡 Hint
Common Mistakes
Using axis=0 which is the y-axis (rows).
Using axis=2 which does not exist in 2D images.
3fill in blank
hard

Fix the error in the code to apply the Laplace filter correctly on the image.

SciPy
from scipy.ndimage import laplace

edges = laplace([1])
Drag options to blanks, or click blank then click option'
Aimage
Bedges
Claplace
Dsobel
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the output variable 'edges' instead of the image.
Passing the function name 'laplace' as argument.
4fill in blank
hard

Fill both blanks to create a dictionary of edge images using Sobel and Laplace filters.

SciPy
edges = {
    'sobel_x': sobel(image, axis=[1]),
    'laplace': [2](image)
}
Drag options to blanks, or click blank then click option'
A0
Blaplace
Csobel
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using axis 0 for sobel_x which detects horizontal edges.
Using 'sobel' instead of 'laplace' for laplace key.
5fill in blank
hard

Fill all three blanks to compute the combined edge magnitude from Sobel edges along x and y axes.

SciPy
edge_x = sobel(image, axis=[1])
edge_y = sobel(image, axis=[2])
edge_magnitude = (edge_x[3]edge_y**2)**0.5
Drag options to blanks, or click blank then click option'
A0
B1
C+
D-
Attempts:
3 left
💡 Hint
Common Mistakes
Using subtraction instead of addition for combining edges.
Swapping axis 0 and 1 for edge_x and edge_y.