summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCharles McGuinness <charles@mcguinness.us>2015-12-14 12:57:11 -0500
committerCharles McGuinness <charles@mcguinness.us>2015-12-14 12:57:11 -0500
commitefee783cb87fe2015ab719699e80a661aa3b4d4b (patch)
tree237dec470d992b2e2e97a31523de10d63a5d6366
parentbfe9d463adc35495826cde5556683d511bdb9693 (diff)
downloadfocusstack-efee783cb87fe2015ab719699e80a661aa3b4d4b.zip
focusstack-efee783cb87fe2015ab719699e80a661aa3b4d4b.tar.gz
focusstack-efee783cb87fe2015ab719699e80a661aa3b4d4b.tar.bz2
Create main.py
-rw-r--r--main.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/main.py b/main.py
new file mode 100644
index 0000000..88d5202
--- /dev/null
+++ b/main.py
@@ -0,0 +1,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 (charles@mcguinness.us)
+ 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!"