-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbasicFunction.py
More file actions
40 lines (29 loc) · 867 Bytes
/
basicFunction.py
File metadata and controls
40 lines (29 loc) · 867 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import cv2 as cv
img = cv.imread('Photos/KenKaneki.jpg')
cv.imshow('Ken', img)
#Converting To Grayscale
gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY )
cv.imshow('Gray Ken', gray)
# Gaussian Blur To Image
blur = cv.GaussianBlur(img,(7,7), cv.BORDER_DEFAULT)
cv.imshow('Blurred Ken', blur)
#Edge Cascading
canny = cv.Canny(img, 125,175)
cv.imshow('Canny Edge Ken', canny)
#Removing Unnecessary Edges
canny = cv.Canny(blur, 125,175)
cv.imshow('Canny Edge Ken', canny)
#Dilating Image
dilated = cv.dilate(canny, (7,7), iterations=1)
cv.imshow('Dilated Image', dilated)
#Eroding
eroded = cv.erode(dilated, (7,7), iterations=1)
cv.imshow('Eorded', eroded)
#Resize
resize = cv.resize(img, (500, 500), interpolation=cv.INTER_CUBIC)
cv.imshow('Resized', resize)
#Cropping
# cropped = img[:, :]
cropped = img[50:200, 200:400]
cv.imshow('Cropped', cropped)
cv.waitKey()