예제 #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
예제 #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)
예제 #3
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)