image-pluser-webui/methods/stack_methods.py
2023-04-18 13:16:16 +03:00

48 lines
1 KiB
Python

from PIL import Image, ImageChops
from tqdm import tqdm
import numpy as np
methods = ["Denoise", "StarTracks", "Noise extractor", "Untrack"]
def denoise(files):
images = [np.asarray(Image.open(file)) for file in tqdm(files)]
return Image.fromarray(np.uint8(np.mean(images, axis=0)))
def startracks(files):
image = Image.open(files[0])
for file in tqdm(files):
im2 = Image.open(file)
im3 = ImageChops.lighter(image, im2)
image = im3
return image
def noise_extractor(files):
image = Image.open(files[0])
for file in tqdm(files, unit=" images"):
im2 = Image.open(file)
im3 = ImageChops.difference(image, im2)
image = im3
return image
def untrack(files):
image = Image.open(files[0])
for file in tqdm(files, unit=" images"):
im2 = Image.open(file)
im3 = ImageChops.darker(image, im2)
image = im3
return image
methods_funcs = {
"Denoise": denoise,
"StarTracks": startracks,
"Noise extractor": noise_extractor,
"Untrack": untrack,
}