Complete the code to apply erosion on the image using OpenCV.
eroded_image = cv2.[1](image, kernel, iterations=1)
The erode function shrinks bright regions in the image, which is the erosion operation.
Complete the code to create a 3x3 rectangular structuring element for morphological operations.
kernel = cv2.getStructuringElement(cv2.MORPH_[1], (3, 3))
The RECT shape creates a rectangular kernel, commonly used in morphological operations.
Fix the error in the code to perform morphological opening on the image.
opened_image = cv2.morphologyEx(image, cv2.MORPH_[1], kernel)MORPH_OPEN applies erosion followed by dilation, which is the opening operation.
Fill both blanks to perform morphological closing on the image with a 5x5 elliptical kernel.
kernel = cv2.getStructuringElement(cv2.MORPH_[1], (5, 5)) closed_image = cv2.morphologyEx(image, cv2.MORPH_[2], kernel)
Using ELLIPSE creates an elliptical kernel, and MORPH_CLOSE applies dilation followed by erosion, which is closing.
Fill all three blanks to create a dilation operation with a 7x7 cross-shaped kernel and 2 iterations.
kernel = cv2.getStructuringElement(cv2.MORPH_[1], (7, 7)) dilated_image = cv2.[2](image, kernel, iterations=[3])
The CROSS kernel shape is used, dilate applies dilation, and 2 sets the number of iterations.