image-pluser-webui/methods/bulk_methods.py

34 lines
687 B
Python
Raw Normal View History

2023-04-16 10:36:29 +03:00
from PIL import Image, ImageFilter
2023-04-17 20:20:27 +03:00
from skimage import feature
import numpy as np
2023-04-16 10:36:29 +03:00
2023-04-18 13:16:16 +03:00
methods = ["Sharpen", "Edge detection", "Canny edge detection"]
2023-04-16 10:36:29 +03:00
2023-04-16 18:40:08 +03:00
def edge(file_name):
2023-04-16 10:36:29 +03:00
image = Image.open(file_name)
image = image.convert("L")
return image.filter(ImageFilter.FIND_EDGES)
2023-04-16 10:46:55 +03:00
2023-04-17 20:20:27 +03:00
def canny_edge(file_name):
image = Image.open(file_name)
image = image.convert("L")
image = np.asarray(image)
return Image.fromarray(feature.canny(image, sigma=2))
2023-04-16 10:46:55 +03:00
def sharpen(file_name):
image = Image.open(file_name)
return image.filter(ImageFilter.SHARPEN)
2023-04-18 13:16:16 +03:00
methods_funcs = {
"Sharpen": sharpen,
"Edge detection": edge,
"Canny edge detection": canny_edge,
}