edge detection opencv python

import cv2
img = cv2.imread(IMG_PATH) #reading the image
edges = cv2.Canny(img,100,200) #canney edhe detecton
cv2.imshow('Edges in the image', edges) #displaying the image

Here is what the above code is Doing:
1. Read the image using cv2.imread()
2. Apply Canny edge detection using cv2.Canny()
3. Show the image using cv2.imshow()

Note: You can also use the following syntax to read an image:

img = cv2.imread(IMG_PATH, 0)

The second parameter is a flag which specifies the way image should be read.

cv2.IMREAD_COLOR : Loads a color image. Any transparency of image will be neglected. It is the default flag.
cv2.IMREAD_GRAYSCALE : Loads image in grayscale mode
cv2.IMREAD_UNCHANGED : Loads image as such including alpha channel

Note: Instead of these three flags, you can simply pass integers 1, 0 or -1 respectively.