Skip to content

Instantly share code, notes, and snippets.

@oostendo
Created October 26, 2012 18:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oostendo/3960617 to your computer and use it in GitHub Desktop.
Save oostendo/3960617 to your computer and use it in GitHub Desktop.
def findShaftTransition(self,img,left_guess,right_guess,top_cutoff):
"""
Walk the line on the shaft find where it starts to bulge out
"""
def transformFromROI(roi, points):
return np.array([(p[0] + roi[0], p[1] + roi[1]) for p in points])
right_guess = sorted(right_guess, key = lambda l: l[1]) #make sure it's bottom, top
roi_delta = 50
right_roi = [right_guess[0][0] - roi_delta, top_cutoff, roi_delta * 2, img.height]
right_crop = img.crop(*right_roi)
edge_locations = np.where(right_crop.getGrayNumpy() > 127)
right_points = transformFromROI(right_roi, zip(*edge_locations))
rhs = np.sort(right_points[right_points[:,0] == right_guess[0][0]], axis = 1)[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment