mirror of
https://github.com/artegoser/image-pluser-webui.git
synced 2024-12-23 09:13:49 +03:00
Merge pull request #2 from artegoser/two_images_proc
feat: histogram matching
This commit is contained in:
commit
a5244a7d4b
5 changed files with 47 additions and 4 deletions
12
methods/two_to_one_methods.py
Normal file
12
methods/two_to_one_methods.py
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
from skimage.exposure import match_histograms
|
||||||
|
import numpy as np
|
||||||
|
from PIL import Image
|
||||||
|
|
||||||
|
|
||||||
|
def histogram_matching(img1, img2):
|
||||||
|
return Image.fromarray(match_histograms(img1, img2, channel_axis=-1))
|
||||||
|
|
||||||
|
|
||||||
|
methods_funcs = {"Histogram matching": histogram_matching}
|
||||||
|
|
||||||
|
methods = list(methods_funcs.keys())
|
|
@ -1,6 +1,4 @@
|
||||||
from methods.stack_methods import (
|
from methods.stack_methods import methods_funcs
|
||||||
methods_funcs,
|
|
||||||
)
|
|
||||||
import os
|
import os
|
||||||
from processing.utils import generate_name
|
from processing.utils import generate_name
|
||||||
|
|
||||||
|
|
10
processing/two_to_one.py
Normal file
10
processing/two_to_one.py
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
from methods.two_to_one_methods import methods_funcs
|
||||||
|
from processing.utils import generate_name
|
||||||
|
|
||||||
|
|
||||||
|
def two_to_one(img1, img2, method):
|
||||||
|
img = methods_funcs[method](img1, img2)
|
||||||
|
out_path = generate_name(subfolder="two_to_one")
|
||||||
|
img.save(out_path)
|
||||||
|
|
||||||
|
return [out_path]
|
17
tabs/Two images to one/app.py
Normal file
17
tabs/Two images to one/app.py
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
import gradio as gr
|
||||||
|
from processing.two_to_one import two_to_one
|
||||||
|
from methods.two_to_one_methods import methods
|
||||||
|
|
||||||
|
with gr.Blocks() as app:
|
||||||
|
gr.Markdown("Get one image from two.")
|
||||||
|
with gr.Row():
|
||||||
|
with gr.Column():
|
||||||
|
img1 = gr.Image()
|
||||||
|
img2 = gr.Image()
|
||||||
|
method = gr.Dropdown(choices=methods, value=methods[0], label="Method")
|
||||||
|
submit = gr.Button("Submit")
|
||||||
|
|
||||||
|
with gr.Column():
|
||||||
|
output = gr.Gallery()
|
||||||
|
|
||||||
|
submit.click(two_to_one, inputs=[img1, img2, method], outputs=[output])
|
|
@ -1 +1,7 @@
|
||||||
tabs = ["Stacking", "Bulk processing", "Images to video", "Video to images"]
|
tabs = [
|
||||||
|
"Stacking",
|
||||||
|
"Bulk processing",
|
||||||
|
"Two images to one",
|
||||||
|
"Images to video",
|
||||||
|
"Video to images",
|
||||||
|
]
|
||||||
|
|
Loading…
Add table
Reference in a new issue