Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
# preprocessing
# gray scale
def gray(img):
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
return img
# blur
def blur(img) :
img_blur = cv2.GaussianBlur(img,(5,5),0)
return img_blur
# threshold
def threshold(img):
#pixels with value below 100 are turned black (0) and those with higher value are turned white (255)
img = cv2.threshold(img, 100, 255, cv2.THRESH_OTSU | cv2.THRESH_BINARY)[1]
return img
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment