OpenCV-Python is a library of Python bindings designed to solve computer vision problems.
cv2.erode() method is used to perform erosion on the image. The basic idea of erosion is just like soil erosion only, it erodes away the boundaries of foreground object (Always try to keep foreground in white). It is normally performed on binary images. It needs two inputs, one is our original image, second one is called structuring element or kernel which decides the nature of operation. A pixel in the original image (either 1 or 0) will be considered 1 only if all the pixels under the kernel is 1, otherwise it is eroded (made to zero).
Syntax: cv2.erode(src, kernel[, dst[, anchor[, iterations[, borderType[, borderValue]]]]])
src: It is the image which is to be eroded .
kernel: A structuring element used for erosion. If element = Mat(), a 3 x 3 rectangular structuring element is used. Kernel can be created using getStructuringElement.
dst: It is the output image of the same size and type as src.
anchor: It is a variable of type integer representing anchor point and it’s default value Point is (-1, -1) which means that the anchor is at the kernel center.
borderType: It depicts what kind of border to be added. It is defined by flags like cv2.BORDER_CONSTANT, cv2.BORDER_REFLECT, etc.
iterations: It is number of times erosion is applied.
borderValue: It is border value in case of a constant border.
Return Value: It returns an image.
Image used for all the below examples:
- Python OpenCV – cv2.flip() method
- Python OpenCV | cv2.rectangle() method
- Python OpenCV - cv2.polylines() method
- Python OpenCV | cv2.arrowedLine() method
- Python OpenCV | cv2.circle() method
- Python OpenCV | cv2.blur() method
- Python OpenCV | cv2.cvtColor() method
- Python OpenCV | cv2.line() method
- Python OpenCV – cv2.transpose() method
- Python OpenCV | cv2.imread() method
- Python OpenCV | cv2.ellipse() method
- Python OpenCV | cv2.putText() method
- Python OpenCV | cv2.imwrite() method
- Python OpenCV | cv2.copyMakeBorder() method
- Python OpenCV | cv2.imshow() method
- Python OpenCV - cv2.rotate() method
- Line detection in python with OpenCV | Houghline method
- Python OpenCV: Optical Flow with Lucas-Kanade method
- Python Program to detect the edges of an image using OpenCV | Sobel edge detection method
- OpenCV - Facial Landmarks and Face Detection using dlib and OpenCV