def completeVeinAngles(veins, buckets=False): complete_vein_angles = [] length = 50 for vein in veins: first_point = vein[0][0] last_point = vein[-1][1] ang = math.floor(util.ang((first_point, last_point), (first_point, (first_point[0] + length, first_point[1])))) if buckets: ang = util.ang((first_point, last_point), (first_point, (first_point[0] + length, first_point[1]))) ang = math.floor(ang / advanced_angle_buckets) complete_vein_angles.append(ang) return sorted(complete_vein_angles)
def extractVeinAngles(veins): for index, vein in enumerate(veins): vein_features['veins'][index] = {} for lindex, line in enumerate(vein): if lindex < len(vein)-1: line2 = vein[lindex+1] line_format = LineString(list(line)) line_2_format = LineString(list(line2)) intersection = line_format.intersection(line_2_format) if not intersection.is_empty: # angle = int(util.ang(line, line2)) angle = math.floor(util.ang(line, line2) / vein_angle_buckets) if line not in vein_features['veins'][index]: vein_features['veins'][index][line] = {} vein_features['veins'][index][line][line2] = angle
def extractIntersections(veins, out_img): for index, vein in enumerate(veins): for index2, vein2 in enumerate(veins): if set(vein) != set(vein2): # TREAT AS POLYLINES for line in vein: for line2 in vein2: line_format = LineString(list(line)) line_2_format = LineString(list(line2)) intersection = line_format.intersection(line_2_format) if not intersection.is_empty: if index not in vein_features['intersections']: vein_features['intersections'][index] = [] angle = math.floor(util.ang(line, line2) / intersection_angle_buckets) supp_angle = math.floor((180 - angle) / intersection_angle_buckets) x_point = int(math.floor(intersection.x)) % point_buckets y_point = int(math.floor(intersection.y)) % point_buckets vein_features['intersections'][index].append((index2, (x_point, y_point), angle, supp_angle)) cv2.circle(out_img, (int(math.floor(intersection.x)), int(math.floor(intersection.y))), 2, (255,245,238), -1)