feat: sharpen method

This commit is contained in:
Artemy 2023-04-16 10:46:55 +03:00
parent 45916cd320
commit 8d9f2a8a17
3 changed files with 21 additions and 10 deletions

View file

@ -7,3 +7,8 @@ def canny_edge(file_name):
image = image.convert("L") image = image.convert("L")
return image.filter(ImageFilter.FIND_EDGES) return image.filter(ImageFilter.FIND_EDGES)
def sharpen(file_name):
image = Image.open(file_name)
return image.filter(ImageFilter.SHARPEN)

View file

@ -2,7 +2,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 canny_edge from methods.bulk_methods import canny_edge, sharpen
def images_to_video(directory, fps, img_ext, img_name_format, video_name, video_ext, video_dir): def images_to_video(directory, fps, img_ext, img_name_format, video_name, video_ext, video_dir):
@ -29,8 +29,14 @@ def video_to_images(video_path, img_ext):
def bulk_processing(directory, out_directory, method): def bulk_processing(directory, out_directory, method):
date = get_date_text() date = get_date_text()
if method == "canny edge": if method == "canny edge":
run_bulk(canny_edge, directory, out_directory, date)
elif method == "sharpen":
run_bulk(sharpen, directory, out_directory, date)
def run_bulk(func, directory, out_directory, date):
for file in os.listdir(directory): for file in os.listdir(directory):
img = canny_edge(os.path.join(directory, file)) img = func(os.path.join(directory, file))
if out_directory: if out_directory:
img_out_path = os.path.join(out_directory, file) img_out_path = os.path.join(out_directory, file)
else: else:

View file

@ -9,7 +9,7 @@ with gr.Blocks() as app:
directory = gr.Text( directory = gr.Text(
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"], value="canny edge", label="Method") choices=["canny edge", "sharpen"], value="canny edge", label="Method")
with gr.Accordion("Advanced settings", open=False) as acc: with gr.Accordion("Advanced settings", open=False) as acc:
out_dir = gr.Text( out_dir = gr.Text(