2023-04-15 19:36:31 +03:00
|
|
|
from PIL import Image, ImageChops
|
|
|
|
from tqdm import tqdm
|
2023-04-17 18:46:59 +03:00
|
|
|
import numpy as np
|
2023-04-15 19:36:31 +03:00
|
|
|
|
|
|
|
|
|
|
|
def denoise(files):
|
2023-04-17 18:46:59 +03:00
|
|
|
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,
|
|
|
|
}
|
2023-04-21 14:25:22 +03:00
|
|
|
|
|
|
|
methods = list(methods_funcs.keys())
|