0
0
Computer Visionml~10 mins

Morphological operations (erosion, dilation, opening, closing) in Computer Vision - Interactive Code Practice

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

Complete the code to apply erosion on the image using OpenCV.

Computer Vision
eroded_image = cv2.[1](image, kernel, iterations=1)
Drag options to blanks, or click blank then click option'
Aerode
Bdilate
Cblur
Dthreshold
Attempts:
3 left
💡 Hint
Common Mistakes
Using dilate instead of erode will expand white regions instead of shrinking them.
Using blur or threshold functions do not perform morphological erosion.
2fill in blank
medium

Complete the code to create a 3x3 rectangular structuring element for morphological operations.

Computer Vision
kernel = cv2.getStructuringElement(cv2.MORPH_[1], (3, 3))
Drag options to blanks, or click blank then click option'
ARECT
BCROSS
CELLIPSE
DSQUARE
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing ELLIPSE or CROSS will create different shaped kernels, not rectangular.
SQUARE is not a valid OpenCV structuring element shape.
3fill in blank
hard

Fix the error in the code to perform morphological opening on the image.

Computer Vision
opened_image = cv2.morphologyEx(image, cv2.MORPH_[1], kernel)
Drag options to blanks, or click blank then click option'
ADILATE
BCLOSE
CERODE
DOPEN
Attempts:
3 left
💡 Hint
Common Mistakes
Using CLOSE applies dilation then erosion, which is the opposite of opening.
Using ERODE or DILATE alone does not perform opening.
4fill in blank
hard

Fill both blanks to perform morphological closing on the image with a 5x5 elliptical kernel.

Computer Vision
kernel = cv2.getStructuringElement(cv2.MORPH_[1], (5, 5))
closed_image = cv2.morphologyEx(image, cv2.MORPH_[2], kernel)
Drag options to blanks, or click blank then click option'
AELLIPSE
BOPEN
CCLOSE
DRECT
Attempts:
3 left
💡 Hint
Common Mistakes
Using RECT instead of ELLIPSE changes the kernel shape.
Using OPEN instead of CLOSE applies the wrong morphological operation.
5fill in blank
hard

Fill all three blanks to create a dilation operation with a 7x7 cross-shaped kernel and 2 iterations.

Computer Vision
kernel = cv2.getStructuringElement(cv2.MORPH_[1], (7, 7))
dilated_image = cv2.[2](image, kernel, iterations=[3])
Drag options to blanks, or click blank then click option'
ACROSS
Bdilate
C2
Derode
Attempts:
3 left
💡 Hint
Common Mistakes
Using ERODE instead of dilate will shrink regions instead of expanding.
Using RECT or ELLIPSE changes the kernel shape.
Setting iterations to 1 or missing it changes the effect strength.