# 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