Esempio n. 1
0
def run(graph, img):
    graph = topology.simplify_junctures(graph)
    log.hsvOrGreyImage(img,
        points=(node for node in graph.nodes() if graph.degree(node) != 2)
    )

    graph = topology.simplify_paths(graph)
    log.hsvOrGreyImage(img,
        points=graph.nodes(),
        lines=graph.edges()
    )

    graph = topology.hv_lines(graph)
    log.hsvOrGreyImage(img,
        points=graph.nodes(),
        lines=graph.edges()
    )

    graph = satisfaction.align(graph)
    log.hsvOrGreyImage(img,
        points=graph.nodes(),
        lines=graph.edges()
    )

    return graph
Esempio n. 2
0
def run(img):
    log.bgrOrGreyImage(img)
    hsv = extract_paper(img, logOn=False)
    log.hsvOrGreyImage(hsv)
    grey = vision.convert_hsv_image_to_greyscale_emphasising_saturation(hsv)
    binarized = vision.binarize_ink_IMPROVED(grey)
    log.hsvOrGreyImage(binarized)
    
    skeleton = vision.skeletonize(binarized)
    log.hsvOrGreyImage(skeleton)
    
    black = np.zeros((hsv.shape[0], hsv.shape[1], 3), dtype=np.uint8)
    
    graph = topology.produce_graph(skeleton, hsv_image=hsv)
    log.hsvOrGreyImage(black,
        pixels=graph.nodes(),
        graph=graph
    )
    
    graph = topology.simplify_junctures(graph)
    log.hsvOrGreyImage(black,
        pixels=graph.nodes(),
        # lines=graph.edges(),
        graph=graph
    )
    
    mygraph, constraint_junctions = topology.find_same_length_constraints(graph)
    log.hsvOrGreyImage(black,
        points=constraint_junctions,
        lines=mygraph.edges(),
        graph=mygraph
    )
    
    graph = topology.simplify_paths(graph)
    log.hsvOrGreyImage(black,
        points=graph.nodes(),
        lines=graph.edges()
    )
    
    graph = topology.hv_lines(graph)
    log.hsvOrGreyImage(hsv,
        points=graph.nodes(),
        lines=graph.edges()
    )
    
    graph = satisfaction.align(graph)
    log.hsvOrGreyImage(hsv,
        points=graph.nodes(),
        lines=graph.edges()
    )
    
    satisfaction.apply_same_length_constraint(graph)
Esempio n. 3
0
def run(img):
    img = extract_paper(img)

    graph = sketch_graph(img)

    graph = topology.simplify_junctures(graph)
    log.hsvOrGreyImage(img, pixels=graph.nodes(), points=(node for node in graph.nodes() if graph.degree(node) != 2))

    paths = topology.find_paths(graph)

    corners = []
    for path in paths:
        corners.extend(corner_detection.find_corners(path))

    log.hsvOrGreyImage(img, points=corners)

    return graph
Esempio n. 4
0
def run(img):
    img = extract_paper(img)

    graph = sketch_graph(img)

    graph = topology.simplify_junctures(graph)
    log.hsvOrGreyImage(img,
                       pixels=graph.nodes(),
                       points=(node for node in graph.nodes()
                               if graph.degree(node) != 2))

    paths = topology.find_paths(graph)

    corners = []
    for path in paths:
        corners.extend(corner_detection.find_corners(path))

    log.hsvOrGreyImage(img, points=corners)

    return graph
Esempio n. 5
0
def run(img):
    log.bgrOrGreyImage(img)
    hsv = extract_paper(img, logOn=False)
    log.hsvOrGreyImage(hsv)
    grey = vision.convert_hsv_image_to_greyscale_emphasising_saturation(hsv)
    binarized = vision.binarize_ink_IMPROVED(grey)
    log.hsvOrGreyImage(binarized)

    skeleton = vision.skeletonize(binarized)
    log.hsvOrGreyImage(skeleton)

    black = np.zeros((hsv.shape[0], hsv.shape[1], 3), dtype=np.uint8)

    graph = topology.produce_graph(skeleton, hsv_image=hsv)
    log.hsvOrGreyImage(black, pixels=graph.nodes(), graph=graph)

    graph = topology.simplify_junctures(graph)
    log.hsvOrGreyImage(
        black,
        pixels=graph.nodes(),
        # lines=graph.edges(),
        graph=graph,
    )

    mygraph, constraint_junctions = topology.find_same_length_constraints(graph)
    log.hsvOrGreyImage(black, points=constraint_junctions, lines=mygraph.edges(), graph=mygraph)

    graph = topology.simplify_paths(graph)
    log.hsvOrGreyImage(black, points=graph.nodes(), lines=graph.edges())

    graph = topology.hv_lines(graph)
    log.hsvOrGreyImage(hsv, points=graph.nodes(), lines=graph.edges())

    graph = satisfaction.align(graph)
    log.hsvOrGreyImage(hsv, points=graph.nodes(), lines=graph.edges())

    satisfaction.apply_same_length_constraint(graph)