-
Notifications
You must be signed in to change notification settings - Fork 0
/
basic.py
34 lines (25 loc) · 776 Bytes
/
basic.py
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
import cv2 as cv
img = cv.imread('Photos/street.jpg')
cv.imshow('Cat', img)
# Converting to grayscale
gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
cv.imshow('Gray', gray)
# Blur - Gauss blur method
blur = cv.GaussianBlur(img, (7,7), cv.BORDER_DEFAULT)
cv.imshow('Blur', blur)
# Edge Cascade - Canny edge detector
canny = cv.Canny(blur, 125, 175)
cv.imshow('Canny Edges', canny)
# Dilating the image
dilated = cv.dilate(canny, (7,7), iterations=3)
cv.imshow('Dilated', dilated)
# Eroding
eroded = cv.erode(dilated, (7,7), iterations=3)
cv.imshow('Eroded', eroded)
# Resize
resized = cv.resize(img, (800,800), interpolation=cv.INTER_CUBIC)
cv.imshow('Resized', resized)
# Cropping - array slicing
cropped = img[50:200, 200:400]
cv.imshow('Cropped', cropped)
cv.waitKey(0)