image-pluser-webui/methods/stack_methods.py

49 lines
1 KiB
Python
Raw Normal View History

2023-04-15 19:36:31 +03:00
from PIL import Image, ImageChops
from tqdm import tqdm
import numpy as np
2023-04-15 19:36:31 +03:00
2023-04-18 13:16:16 +03:00
methods = ["Denoise", "StarTracks", "Noise extractor", "Untrack"]
2023-04-15 19:36:31 +03:00
def denoise(files):
images = [np.asarray(Image.open(file)) for file in tqdm(files)]
return Image.fromarray(np.uint8(np.mean(images, axis=0)))
2023-04-15 19:36:31 +03:00
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])
2023-04-16 18:40:08 +03:00
for file in tqdm(files, unit=" images"):
2023-04-15 19:36:31 +03:00
im2 = Image.open(file)
im3 = ImageChops.difference(image, im2)
image = im3
return image
def untrack(files):
image = Image.open(files[0])
2023-04-16 18:40:08 +03:00
for file in tqdm(files, unit=" images"):
2023-04-15 19:36:31 +03:00
im2 = Image.open(file)
im3 = ImageChops.darker(image, im2)
image = im3
return image
2023-04-18 13:16:16 +03:00
methods_funcs = {
"Denoise": denoise,
"StarTracks": startracks,
"Noise extractor": noise_extractor,
"Untrack": untrack,
}