-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasicFunctions.py
More file actions
43 lines (26 loc) · 944 Bytes
/
Copy pathbasicFunctions.py
File metadata and controls
43 lines (26 loc) · 944 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
41
42
43
import cv2 as cv
img = cv.imread('Photos/cat.jpeg')
cv.imshow('Cats', img)
# Converting an image(bgr) to grayscale
gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
cv.imshow('Grayed Image', gray)
# Blurring an image(using the Gaussian Blur)
blur = cv.GaussianBlur(img, (7, 7), cv.BORDER_DEFAULT)
cv.imshow('Blurred', blur)
# Edge cascade (finding the edges present in an image)
# you can get rid of many edges by adding a lot of blur to the images
canny = cv.Canny(blur, 125, 175)
cv.imshow("Canny Edges Cascading", canny)
# Dilating an image
dilated = cv.dilate(canny, (7, 7), iterations=3)
cv.imshow('Dilated ', dilated)
# Eroding an image
eroded = cv.erode(dilated, (7, 7), iterations=3)
cv.imshow('Eroded', eroded)
# Resizing an image
resized = cv.resize(img, (500, 500), interpolation=cv.INTER_CUBIC)
cv.imshow('Resized', resized)
# Cropping an image
cropped = img[48:200, 200: 400]
cv.imshow("Cropped ", cropped)
cv.waitKey(0)