Created
August 2, 2020 13:35
-
-
Save tanviredu/141a2e72d2bd4f96c5cc67fce45a7f21 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def Otsus_Binarization(folder,target): | |
images = [] | |
i=1 | |
for file in os.listdir(folder): | |
try: | |
img = cv2.imread(os.path.join(folder,file),cv2.IMREAD_GRAYSCALE) | |
ret2,th2 = cv.threshold(img,0,255,cv.THRESH_BINARY+cv.THRESH_OTSU) | |
except: | |
pass | |
if img is not None: | |
print("[+] {} is loaded".format(i)) | |
images.append([th2,target]) | |
i+=1 | |
else: | |
print("[-] Problem importing" ) | |
return images | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment