Last active
April 25, 2020 09:43
-
-
Save aniruddha27/976dd6ff5ba3d8a1dfed64dc8698ea2b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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