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
4 changes: 2 additions & 2 deletions GetLargestContour.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@
cv2.drawContours(output, hull, -1, (0,255,0), 2)
largestcontourarea = cv2.contourArea(hull[0])

for p in hull[0]:
polygon.append({'x':p[0][0], 'y':p[0][1]})
for p in np.atleast_2d(np.squeeze(hull[0])):
polygon.append({'x':p[0], 'y':p[1]})
#cv2.rectangle(output,(x,y),(x+w,y+h),(0,255,0),2)

sd = CropPolygonsToSingleImage()
Expand Down
2 changes: 1 addition & 1 deletion ImageProcess/CalculatePhenotypeSift.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
result_file_lines = []
for image in images:
img = cv2.imread(image)
descriptor = cv2.xfeatures2d.SIFT_create()
descriptor = cv2.SIFT_create()
(kps, features) = descriptor.detectAndCompute(img, None)
print(features)
result_file_lines.append([len(kps)])
Expand Down
2 changes: 1 addition & 1 deletion ImageProcess/MatchAndAlignImages.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
img2 = cv2.imread(input_image1, cv2.IMREAD_UNCHANGED)

# orb = cv2.ORB_create(MAX_FEATURES)
orb = cv2.xfeatures2d.SIFT_create(MAX_FEATURES)
orb = cv2.SIFT_create(MAX_FEATURES)
keypoints1, descriptors1 = orb.detectAndCompute(img1, None)
keypoints2, descriptors2 = orb.detectAndCompute(img2, None)

Expand Down
2 changes: 1 addition & 1 deletion ImageProcess/MergeChannels.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def align_images(moving, fixed_im):
moving_im = b

# Initiate SIFT detector
sift = cv2.xfeatures2d.SIFT_create()
sift = cv2.SIFT_create()
print("GET SIFT")

# find the keypoints and descriptors with SIFT
Expand Down
3 changes: 2 additions & 1 deletion ImageProcess/RemoveBackground.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@

src = cv2.imread(input_image, cv2.IMREAD_GRAYSCALE)

th, dst = cv2.threshold(src, int(float(lower_thresh)), int(float(upper_thresh)), cv2.THRESH_TOZERO)
th, dst = cv2.threshold(src, int(float(lower_thresh)), 0, cv2.THRESH_TOZERO) # zero out pixels darker than lower_thresh
th, dst = cv2.threshold(dst, int(float(upper_thresh)), 0, cv2.THRESH_TOZERO_INV) # zero out pixels brighter than upper_thresh

#cv2.imshow("Result", dst)
cv2.imwrite(outfile_path, dst)
Expand Down
14 changes: 9 additions & 5 deletions ImageProcess/RemoveBackgroundPercentage.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
img_shape = img.shape

if len(img_shape) == 3:
if img_shape[2] == 4:
img = cv2.cvtColor(img, cv2.COLOR_BGRA2BGR) # drop the alpha channel so it is not thresholded along with the color channels
img_shape = img.shape
if img_shape[2] == 3:
b,g,r = cv2.split(img)
if image_band_index is not None:
Expand All @@ -41,7 +44,7 @@
img = r


hist = cv2.calcHist([img],[0],None,histSize,[0,255])
hist = cv2.calcHist([img],[0],None,histSize,[0,256]).flatten()

#print(hist)
#print(img.shape)
Expand All @@ -51,16 +54,16 @@
drone_imagery_remove_background_lower_percentage_threshold = 0
drone_imagery_remove_background_upper_percentage_threshold = 0
for i in range(0, histSize[0]):
binVal = hist[i][0]
binVal = hist[i]
summing = summing + binVal
percentage = summing / total_pixels
if percentage >= lower_percentage:
drone_imagery_remove_background_lower_percentage_threshold = i
break

summing = 0;
summing = 0
for i in range(0, histSize[0]):
binVal = hist[i][0]
binVal = hist[i]
summing = summing + binVal
percentage = summing / total_pixels
if percentage >= 1-upper_percentage:
Expand All @@ -69,7 +72,8 @@

lower_thresh = int(float(drone_imagery_remove_background_lower_percentage_threshold))
upper_thresh = int(float(drone_imagery_remove_background_upper_percentage_threshold))
th, dst = cv2.threshold(img, lower_thresh, upper_thresh, cv2.THRESH_TOZERO)
th, dst = cv2.threshold(img, lower_thresh, 0, cv2.THRESH_TOZERO) # zero out the darkest lower_percentage of pixels
th, dst = cv2.threshold(dst, upper_thresh, 0, cv2.THRESH_TOZERO_INV) # zero out the brightest upper_percentage of pixels

cv2.imwrite(outfile_path, dst)
#cv2.waitKey(0)
2 changes: 1 addition & 1 deletion ImageStitching/Panorama/Panorama.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def detectAndDescribe(self, image):

# Only works in OpenCV 3.X
# detect and extract features from the image
descriptor = cv2.xfeatures2d.SIFT_create()
descriptor = cv2.SIFT_create()
(kps, features) = descriptor.detectAndCompute(image, None)

# convert the keypoints from KeyPoint objects to NumPy arrays
Expand Down