Last active 2 months ago

mga's Avatar mga revised this gist 2 months ago. Go to revision

No changes

mga's Avatar mga revised this gist 2 months ago. Go to revision

1 file changed, 31 insertions

starmax.py(file created)

@@ -0,0 +1,31 @@
1 + import cv2
2 + import numpy as np
3 + import os
4 + import argparse
5 +
6 +
7 + parser = argparse.ArgumentParser(
8 + description="""Takes in a path to a directory
9 + of images and stacks them into a star trail image."""
10 + )
11 + parser.add_argument("path", help="Path to a directory containing images of stars")
12 +
13 + parser.add_argument("--name", help="Name of output file")
14 +
15 + args = parser.parse_args()
16 + path = args.path
17 + name = args.name
18 +
19 + if name is None:
20 + name = "out.jpg"
21 +
22 + im, prev = None, None
23 + for file in os.listdir(path):
24 + if os.path.splitext(file)[1].lower() == ".jpg":
25 + curr = cv2.imread(path + file)
26 + if im is None:
27 + im = curr
28 + else:
29 + im = np.maximum(im, curr)
30 +
31 + cv2.imwrite(name, im)
Newer Older