forked from cmcguinness/focusstack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
37 lines (26 loc) · 981 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import os
import cv2
import FocusStack
"""
Focus stack driver program
This program looks for a series of files of type .jpg, .jpeg, or .png
in a subdirectory "Input" and then merges them together using the
FocusStack module. The output is put in the file merged.png
Author: Charles McGuinness ([email protected])
Copyright: Copyright 2015 Charles McGuinness
License: Apache License 2.0
"""
def stackHDRs(image_files):
focusimages = []
for img in image_files:
print("Reading in file {}".format(img))
focusimages.append(cv2.imread("Input/{}".format(img)))
merged = FocusStack.focus_stack(focusimages)
cv2.imwrite("merged.png", merged)
if __name__ == "__main__":
image_files = sorted(os.listdir("Input"))
for img in image_files:
if img.split(".")[-1].lower() not in ["jpg", "jpeg", "png"]:
image_files.remove(img)
stackHDRs(image_files)
print("That's All Folks!")