Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Importing laplace instead of sobel.
Using gaussian_filter which is for smoothing, not edge detection.
✗ Incorrect
The Sobel filter is imported from scipy.ndimage as 'sobel'.
2fill in blank
mediumComplete 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'
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.
✗ Incorrect
Axis 1 corresponds to the x-axis (columns) in the image array for the Sobel filter.
3fill in blank
hardFix 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the output variable 'edges' instead of the image.
Passing the function name 'laplace' as argument.
✗ Incorrect
The Laplace filter function takes the image array as input, so 'image' must be passed.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using axis 0 for sobel_x which detects horizontal edges.
Using 'sobel' instead of 'laplace' for laplace key.
✗ Incorrect
Sobel filter along axis 1 detects vertical edges; laplace is called as a function on image.
5fill in blank
hardFill 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'
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.
✗ Incorrect
Sobel edges along axis 1 (x) and 0 (y) are combined by adding squares and taking square root for magnitude.