Skip to content

Commit 97011a1

Browse files
Otsu Threading
1 parent a99f1ea commit 97011a1

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Linkedin/Opencv/otsu_threading.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# otsu threading ---> https://www.geeksforgeeks.org/python-thresholding-techniques-using-opencv-set-3-otsu-thresholding/
2+
'We use the Traditional cv2.threshold function and use cv2.THRESH_OTSU as an extra flag.'
3+
import cv2
4+
img=cv2.imread('sudoku.png',0)
5+
cv2.imshow('Original',img)
6+
7+
# simaple threading ---> problem ---> uneven binding
8+
ret,frame=cv2.threshold(img,85,255,cv2.THRESH_BINARY)
9+
cv2.imshow('Binary',frame)
10+
11+
# otsu
12+
ret,frame=cv2.threshold(img,85,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU)
13+
cv2.imshow('Otsu',frame)
14+
15+
cv2.waitKey(0)
16+
cv2.destroyAllWindows()

0 commit comments

Comments
 (0)