Ejemplo n.º 1
0
def edge_tester2(points, image, circle, N, pct = False):
    if len(points) < 10: N = len(points)
    if pct:
        N = round(N/100*len(points))

    distances =  [[gs.distance(x, y) for x in points] for y in points]
    #used = []
    edges = []

    for start in points:
        index = points.index(start)
        row = distances[index]
        mins = heapq.nsmallest(N,row)

        neighbors = [points[row.index(x)] for x in mins]
        for end in neighbors:
            if start == end:
                continue
            else:
                try:
                    val = gs.is_edge(start, end, image, points, circle)
                except IndexError:
                    print("Start = {}; End = {}".format(start, end))
                    print("Hit an out-of-bound index.")
                    continue
                except Exception as e:
                    print("Start = {}; End = {}".format(start, end))
                    print("Hit some other error: {}.".format(e))
                    continue
                else:
                    if val:
                        edges.append([points.index(start), points.index(end)])
        #used.append(start)
    return edges
Ejemplo n.º 2
0
#cir = copy.deepcopy(cirDict)
pass
step4 = timeit.default_timer()

keyA = "({x},{y})".format(x = int(a[0]), y = int(a[1]))
circle = cirDict[keyA]
step5 = timeit.default_timer()

del cirDict[keyA]
finish_setup = timeit.default_timer()

newpoint = a
minDist = 999999
for c in circle:
   if gs.distance(c, b) < minDist:
       minDist = gs.distance(c,b)
       newpoint = c
a = newpoint

adjust_a = timeit.default_timer()

for item in cirDict.values():
    for point in item:
        if point[0] > width: point[0] = width
        if point[1] > height: point[1] = height
        p.append(point)


endzone = gs.full_circle(b, gs.biggest_circle(b,im), im.shape)