Beispiel #1
0
def test_all_intermediate_levels(img_file, rect=None, levels=None):
    img = misc.imread(img_file)

    if rect is None:
        rect = RR.RectangularRegion((50, 50), (50, 70), (70, 70), (70, 50))

    if levels is None:
        levels = [5 * i for i in range(0, 51)]

    grid = HI.region_to_half_grid(rect)
    extended_grid = HI.add_level_information(img, grid)

    tjoints_grid = {}
    for level in levels:
        level_line = LL.compute_level_line(img, level)
        level_intersection = RI.intersect_region_level_line(
            rect.extended_boundary, level_line)

        tjoints_grid.update(
            compute_level_tjoints(extended_grid, level_intersection))

    extended_tjoints = create_intermediate_levels(tjoints_grid)

    list_tjoints = extended_tjoints.values()
    list_tjoints = sorted(list_tjoints, key=lambda x: x["order"])
    for data in list_tjoints:
        print(data["grid"], " : ", data["levels"])
Beispiel #2
0
def test_tjoints_levels(img_file, rect=None, levels=None):
    img = misc.imread(img_file)

    if rect is None:
        rect = RR.RectangularRegion((50, 50), (50, 70), (70, 70), (70, 50))

    if levels is None:
        levels = [5 * i for i in range(0, 51)]

    grid = HI.region_to_half_grid(rect)
    extended_grid = HI.add_level_information(img, grid)

    tjoints_grid = {}

    for level in levels:
        level_line = LL.compute_level_line(img, level)
        level_intersection = RI.intersect_region_level_line(
            rect.extended_boundary, level_line)

        tjoints_grid.update(
            compute_level_tjoints(extended_grid, level_intersection))

    # print( len(tjoints_grid.keys()) )

    x = []
    y = []
    for k, v in tjoints_grid.items():
        x.append(k[0])
        y.append(k[1])

    plt.plot(x, y, 'bo')
    plt.show()
Beispiel #3
0
def test_match(img_file, rect=None, levels=None):
    img = misc.imread(img_file)

    if rect is None:
        rect = RR.RectangularRegion((50, 50), (50, 70), (70, 70), (70, 50))

    if levels is None:
        levels = [5 * i for i in range(0, 51)]

    grid = HI.region_to_half_grid(rect)
    extended_grid = HI.add_level_information(img, grid)

    tjoints_grid = {}

    for level in levels:
        level_line = LL.compute_level_line(img, level)
        level_intersection = RI.intersect_region_level_line(
            rect.extended_boundary, level_line)

        tjoints_grid.update(
            TJ.compute_level_tjoints(extended_grid, level_intersection))

    extended_tjoints = TJ.create_intermediate_levels(tjoints_grid)

    for k, v in extended_tjoints.items():
        extended_tjoints[k]["grid"] = k

    tjoints_list = sorted(extended_tjoints.values(), key=lambda x: x["order"])

    connections = match_tjoints_pairs(tjoints_list)
    print(connections)
Beispiel #4
0
def test_intermediate_levels(img_file, level, rect=None):
    img = misc.imread(img_file)

    if rect is None:
        rect = RR.RectangularRegion((50, 50), (50, 70), (70, 70), (70, 50))

    level_line = LL.compute_level_line(img, level)

    grid = HI.region_to_half_grid(rect)
    extended_grid = HI.add_level_information(img, grid)

    level_intersection = RI.intersect_region_level_line(
        rect.extended_boundary, level_line)

    tjoints_grid = compute_level_tjoints(extended_grid, level_intersection)
    extended_tjoints = create_intermediate_levels(tjoints_grid)

    for k, v in extended_tjoints.items():
        print(v["levels"])