
Then we take the kernel matrix size (6,6). In the arguments of the function, we are giving the location of the Binary image, if the image is in the same folder then we only give the name of the image as the argument of the imread() function. Then using the NumPy module we are reading the image using imread() function.

So, At first, we are importing cv2 and numpy in Python (Make sure, You’ve installed the OpenCV before writing the code). To make Erosion happen we use cv2.erode() function. The colors of Binary image is represented by 0 and 1 But sometimes it is also represented as 0 and 255). We apply Erosion only to the binary image(The image which consists only two colors black and white. Erosion is basically omitting or thining the boundaries of the bright area of the image.
#PYTHON OPENCV MAC INSTALL#
pip install numpy cv2.erode() function in Python – OpenCVĮrosion is one of the most important operations in Morphological Transformation. To install NumPy you have to run the following comment in your command prompt or terminal (for Linux or Mac users) then it will be installed.

#PYTHON OPENCV MAC DOWNLOAD#
To install OpenCV You have to download the OpenCV program and run it on your computer and install it as a normal installation.

We are going to do this using OpenCV and NumPy packages if you have already installed open CV and NumPy then you can ignore otherwise you have to install open CV and NumPy. So let’s learn how we can imply it in Python and see its Output. The function is actually packed in the OpenCV package in Python. In this tutorial, we are going to learn cv2.erode() function.This is basically an operation in Morphological Transformation.
