def All_images_filter_dilate_blur(path, dstpath, blur, iteration, log_file): """ Applique les filtres {BlurryImage.blur_filter()}, {DilatedImage.dilated_image()} à toutes les images d'un dossier :param path: folder where to collect images :param dstpath: folder where to put the modified images :param blur: desired blur intensity :param iteration: number of times the pixels should dilate """ try: makedirs(dstpath) except: print("Directory already exist, images will be written in " + dstpath + " folder") # Folder won't used files = os.listdir(path) for image in files: try: img = cv2.imread(os.path.join(path, image)) img = BlurryImage.blur_filter(img, blur) img = DilatedImage.dilated_image(img, iteration) cv2.imwrite(os.path.join(dstpath, image), img) except cv2.error as e: print(e) logger.log('Filter dilate and blur applied', log_file) print('Filter dilate and blur applied')
def All_images_filter_dilated_text(path, dstpath, iteration, log_file): """ Applique les filtres {DilatedImage.dilated_image()},{FilterZeTeam.text_filter()} à toutes les images d'un dossier :param path: folder where to collect images :param dstpath: folder where to put the modified images :param blur: desired blur intensity """ try: makedirs(dstpath) except: print("Directory already exist, images will be written in " + dstpath + " folder") # Folder won't used files = os.listdir(path) for image in files: try: img = cv2.imread(os.path.join(path, image)) img = DilatedImage.dilated_image(img, iteration) img = FilterZeTeam.text_filter(img) cv2.imwrite(os.path.join(dstpath, image), img) except cv2.error as e: print(e) logger.log('Filters dilate and text are applied', log_file) print('Filters dilate and text are applied')
GrayScale.All_images_filter_grey_scale(path, dstpath, log_file) elif (iteration == None) and (grayscale == None) and (blur != None) and (text == None): blur = int(blur) if ((blur % 2) == 0) or (blur < 0): print('The blur need to be positive and odd') else: BlurryImage.All_images_filter_blurry(path, dstpath, blur, log_file) elif (iteration == None) and (grayscale == None) and (blur != None) and (text == ''): blur = int(blur) if ((blur % 2) == 0) or (blur < 0): print('The blur need to be positive and odd') else: All_images.All_images_filter_text_blurry(path, dstpath, blur, log_file) elif (iteration != None) and (grayscale == None) and (blur == None) and (text == None): iteration = int(iteration) DilatedImage.All_images_filter_dilated(path, dstpath, iteration, log_file) elif (iteration != None) and (grayscale == None) and (blur == None) and (text == ''): iteration = int(iteration) All_images.All_images_filter_dilated_text(path, dstpath, iteration, log_file) elif (iteration != None) and (grayscale == None) and (blur != None) and (text == None): iteration = int(iteration) blur = int(blur) if ((blur % 2)== 0) or (blur < 0): print('The blur need to be positive and odd') else: All_images.All_images_filter_dilate_blur(path, dstpath, blur, iteration, log_file) elif (iteration != None) and (grayscale == None) and (blur != None) and (text == ''): iteration = int(iteration) blur = int(blur) if ((blur % 2)== 0) or (blur < 0): print('The blur need to be positive and odd')