-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcanny-gaussian-prefilter.py
More file actions
27 lines (21 loc) · 909 Bytes
/
canny-gaussian-prefilter.py
File metadata and controls
27 lines (21 loc) · 909 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
import cv2
import numpy
# In this canny sample we return license plates...
# canny-gaussian-prefilter.py returns nicer letters,
# but with diminished corners.
pic = cv2.imread(r'images/usa_plates02.jpg')#usa_plates01.jpg
# RTFM: https://docs.opencv.org/2.4/modules/imgproc/doc/filtering.html#gaussianblur
kernel = (21,17) # Gaussian kernels *must* be odd
stdev = 3 # 0.1 introduces much detail
blur = cv2.GaussianBlur(pic, kernel, stdev)
# Returning an image called blur, convolving low-probability high-amplitude noise from the image.
# Aggressivly reduce noise
# Output GaussianBlur to screen:
#cv2.imshow('Gaussian Blur Sample', blur)
threshold1 = 50
threshold2 = 100
filter = cv2.Canny(blur, threshold2, threshold2)
#Canny uses apertureSize=3 by default: https://docs.opencv.org/3.2.0/dd/d1a/group__imgproc__feature.html
cv2.imshow('Canny Edge Sample', filter)
cv2.waitKey()
cv2.destroyAllWindows()