mirror of
https://github.com/artegoser/image-pluser-webui.git
synced 2024-11-24 12:36:22 +03:00
feat: canny edge
This commit is contained in:
parent
26702d57f1
commit
3f1d13c1c0
3 changed files with 17 additions and 3 deletions
|
@ -1,4 +1,6 @@
|
|||
from PIL import Image, ImageFilter
|
||||
from skimage import feature
|
||||
import numpy as np
|
||||
|
||||
|
||||
def edge(file_name):
|
||||
|
@ -9,6 +11,14 @@ def edge(file_name):
|
|||
return image.filter(ImageFilter.FIND_EDGES)
|
||||
|
||||
|
||||
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))
|
||||
|
||||
|
||||
def sharpen(file_name):
|
||||
image = Image.open(file_name)
|
||||
return image.filter(ImageFilter.SHARPEN)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import ffmpeg
|
||||
import os
|
||||
from processing.utils import generate_name, get_date_text, generate_name_with_file_name
|
||||
from methods.bulk_methods import edge, sharpen
|
||||
from methods.bulk_methods import edge, sharpen, canny_edge
|
||||
|
||||
|
||||
def images_to_video(
|
||||
|
@ -33,7 +33,9 @@ def bulk_processing(directory, out_directory, method):
|
|||
date = get_date_text()
|
||||
if method == "Edge detection":
|
||||
run_bulk(edge, directory, out_directory, date)
|
||||
elif method == "sharpen":
|
||||
elif method == "Canny edge detection":
|
||||
run_bulk(canny_edge, directory, out_directory, date)
|
||||
elif method == "Sharpen":
|
||||
run_bulk(sharpen, directory, out_directory, date)
|
||||
|
||||
|
||||
|
|
|
@ -11,7 +11,9 @@ with gr.Blocks() as app:
|
|||
placeholder="A directory with many images.", lines=1, label="Directory"
|
||||
)
|
||||
method = gr.Dropdown(
|
||||
choices=["canny edge", "sharpen"], value="canny edge", label="Method"
|
||||
choices=["Edge detection", "Canny edge detection", "sharpen"],
|
||||
value="Sharpen",
|
||||
label="Method",
|
||||
)
|
||||
|
||||
with gr.Accordion("Advanced settings", open=False) as acc:
|
||||
|
|
Loading…
Add table
Reference in a new issue