-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic.py
More file actions
executable file
·36 lines (28 loc) · 873 Bytes
/
basic.py
File metadata and controls
executable file
·36 lines (28 loc) · 873 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
import cv2 as cv
import numpy as np
img=cv.imread('/home/prabhat/Desktop/Code/OpenCV_Basics/Photos/park.jpg')
cv.imshow('Boston',img)
#converting an image to grayscale
#BGR to greyscale
grey=cv.cvtColor(img, cv.COLOR_BGR2GRAY )
cv.imshow('grey',grey)
#Blur
blur=cv.GaussianBlur(img,(5,5),cv.BORDER_DEFAULT)
cv.imshow('Blur',blur)
#Edge Cascade
canny=cv.Canny(blur, 125, 175)
cv.imshow('Canny image',canny)
#Dilating images
dilated=cv.dilate(canny, (8,8),iterations=1)
cv.imshow("Dilated",dilated)
#eroding
eroded=cv.erode(dilated,(9,9),iterations=1)
cv.imshow("Eroded",eroded)
#resize
resized=cv.resize(eroded,(500,500))
#interpolation=cv.INTER_AREA to compress and cv.INTER_LINEAR/CUBIC for enlarging at good quality
cv.imshow("Resized",resized)
#cropping
cropped=img[50:300,20:400]
cv.imshow("Cropped",cropped)
cv.waitKey(0)