diff --git a/FocusStack.py b/FocusStack.py index 36ec099..059df32 100644 --- a/FocusStack.py +++ b/FocusStack.py @@ -69,13 +69,13 @@ def align_images(images): detector = cv2.ORB_create(1000) # We assume that image 0 is the "base" image and align everything to it - print "Detecting features of base image" + print("Detecting features of base image") outimages.append(images[0]) image1gray = cv2.cvtColor(images[0],cv2.COLOR_BGR2GRAY) image_1_kp, image_1_desc = detector.detectAndCompute(image1gray, None) for i in range(1,len(images)): - print "Aligning image {}".format(i) + print("Aligning image {}".format(i)) image_i_kp, image_i_desc = detector.detectAndCompute(images[i], None) if use_sift: @@ -126,14 +126,14 @@ def doLap(image): def focus_stack(unimages): images = align_images(unimages) - print "Computing the laplacian of the blurred images" + print("Computing the laplacian of the blurred images") laps = [] for i in range(len(images)): - print "Lap {}".format(i) + print("Lap {}".format(i)) laps.append(doLap(cv2.cvtColor(images[i],cv2.COLOR_BGR2GRAY))) laps = np.asarray(laps) - print "Shape of array of laplacians = {}".format(laps.shape) + print("Shape of array of laplacians = {}".format(laps.shape)) output = np.zeros(shape=images[0].shape, dtype=images[0].dtype) @@ -144,4 +144,4 @@ def focus_stack(unimages): for i in range(0,len(images)): output = cv2.bitwise_not(images[i],output, mask=mask[i]) - return 255-output \ No newline at end of file + return 255-output diff --git a/main.py b/main.py index 88d5202..69ebcb6 100644 --- a/main.py +++ b/main.py @@ -6,7 +6,7 @@ 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 + in a subdirectory "Input" and then merges them together using the FocusStack module. The output is put in the file merged.png @@ -19,19 +19,19 @@ def stackHDRs(image_files): focusimages = [] for img in image_files: - print "Reading in file {}".format(img) - focusimages.append(cv2.imread("input/{}".format(img))) + 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")) + 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!" + print("That's All Folks!")