Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions FocusStack.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,18 @@ def align_images(images):
outimages = []

if use_sift:
detector = cv2.xfeatures2d.SIFT_create()
detector = cv2.SIFT.create()
else:
detector = cv2.ORB_create(1000)
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:
Expand Down Expand Up @@ -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)

Expand All @@ -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
return 255-output
4 changes: 2 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
def stackHDRs(image_files):
focusimages = []
for img in image_files:
print "Reading in file {}".format(img)
print("Reading in file {}".format(img))
focusimages.append(cv2.imread("input/{}".format(img)))

merged = FocusStack.focus_stack(focusimages)
Expand All @@ -34,4 +34,4 @@ def stackHDRs(image_files):


stackHDRs(image_files)
print "That's All Folks!"
print("That's All Folks!")