Modules used:
For this, we will use the opencv-python module which provides us various functions to work on images.
Download opencv-python
General Way:
pip install opencv-python
Pycharm Users:
Go to the project Interpreter and install this module from there.
opencv-python Module:
opencv-python is a python library that will solve the Computer Vision Problems and provides us various functions to edit the Images.
Note: The edge Detection is possible only in grayscale Image.
What we will do in this script?
To detect the edges of the images we will use opencv-python various Functions and Provide thresholds.
In this article we will detect the edge of the Image with the help of various functions and the accuracy of edge increases as we go down,
- Sobel Function: This Function will create the Horizontal and vertical edges and after that, we will use the Bitwise or operator to combine them
- Laplacian Function: This Function is the simplest Function in which we just have to put the Grayscale Variable into it, and we will get the edge detected image.
- Canny Function: This is the most powerful function for edge detection and most accurate.
1) Using Sobel Function
Output:
2) Laplacian Function
Output:
3) Using Canny Function
Output:

need an explanation for this answer? contact us directly to get an explanation for this answer