Пример #1
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)
Пример #2
0
def run(img):
    img = vision.convert_hsv_image_to_greyscale_emphasising_saturation(img)
    ink = vision.binarize_ink_IMPROVED(img)
    log.bgrOrGreyImage(ink)

    skeleton = vision.skeletonize(ink)
    log.bgrOrGreyImage(skeleton)

    graph = topology.produce_graph(skeleton)
    log.hsvOrGreyImage(img, pixels=graph.nodes())
    log.gpickle(graph)

    return graph
Пример #3
0
def run(img):
    img = vision.convert_hsv_image_to_greyscale_emphasising_saturation(img)
    ink = vision.binarize_ink_IMPROVED(img)
    log.bgrOrGreyImage(ink)

    skeleton = vision.skeletonize(ink)
    log.bgrOrGreyImage(skeleton)

    graph = topology.produce_graph(skeleton)
    log.hsvOrGreyImage(img,
        pixels=graph.nodes()
    )
    log.gpickle(graph)

    return graph
Пример #4
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)