Skip to content

Instantly share code, notes, and snippets.

@aniruddha27
Last active April 25, 2020 09:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aniruddha27/976dd6ff5ba3d8a1dfed64dc8698ea2b to your computer and use it in GitHub Desktop.
Save aniruddha27/976dd6ff5ba3d8a1dfed64dc8698ea2b to your computer and use it in GitHub Desktop.
# preprocessing
# gray scale
def gray(img):
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
cv2.imwrite(r"./preprocess/img_gray.png",img)
return img
# blur
def blur(img) :
img_blur = cv2.GaussianBlur(img,(5,5),0)
cv2.imwrite(r"./preprocess/img_blur.png",img)
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]
cv2.imwrite(r"./preprocess/img_threshold.png",img)
return img
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment