mirror of
https://github.com/artegoser/image-pluser-webui.git
synced 2024-11-24 20:46: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 PIL import Image, ImageFilter
|
||||||
|
from skimage import feature
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
|
||||||
def edge(file_name):
|
def edge(file_name):
|
||||||
|
@ -9,6 +11,14 @@ def edge(file_name):
|
||||||
return image.filter(ImageFilter.FIND_EDGES)
|
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):
|
def sharpen(file_name):
|
||||||
image = Image.open(file_name)
|
image = Image.open(file_name)
|
||||||
return image.filter(ImageFilter.SHARPEN)
|
return image.filter(ImageFilter.SHARPEN)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import ffmpeg
|
import ffmpeg
|
||||||
import os
|
import os
|
||||||
from processing.utils import generate_name, get_date_text, generate_name_with_file_name
|
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(
|
def images_to_video(
|
||||||
|
@ -33,7 +33,9 @@ def bulk_processing(directory, out_directory, method):
|
||||||
date = get_date_text()
|
date = get_date_text()
|
||||||
if method == "Edge detection":
|
if method == "Edge detection":
|
||||||
run_bulk(edge, directory, out_directory, date)
|
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)
|
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"
|
placeholder="A directory with many images.", lines=1, label="Directory"
|
||||||
)
|
)
|
||||||
method = gr.Dropdown(
|
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:
|
with gr.Accordion("Advanced settings", open=False) as acc:
|
||||||
|
|
Loading…
Add table
Reference in a new issue