Basic Functions

import cv2

img = cv2.imread("Resources/Wally.jpg")

imgGray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

cv2.imshow("Gray Image", imgGray)
cv2.waitKey(0)

ksize = kernelSize of matrix which is (7, 7) in our case.

xSigma = 0, when you increase the value of xSigma you basically get more blur.

imgBlur = cv2.GaussianBlur(imgGray, (7,7), 0) #imgGray is the source picture
cv2.imshow("Blur Image", imgBlur)
imgCanny = cv2.Canny(img,100,100)

We need a little bit matrix here, therefore, we're gonna import another package which is called numpy

import numpy as np
kernel = np.ones((5,5),np.uint8)
imgDialation = cv2.dilate(imgCanny, kernel, iterations=1)
cv2.imshow("Dialation Image", imgDialation)
kernel = np.ones((5,5), np.uint8)
imgEroded = cv2.erode(imgDialation, kernel, iterations=1)

Last updated