Пример #1
0
def setup_graph_type_2_with_all_lines() -> nx.MultiDiGraph:
    line_data = import_data.read_relation_data()
    line_cluster = create_cluster_using_all_lines(line_data)
    relation_sets: Dict[int,
                        ValuesView[RelationData]] = line_cluster.relation_sets

    cluster_graph: nx.MultiDiGraph = nx.MultiDiGraph()

    for relation_set_id in relation_sets:
        line_graph = create_cluster_from_relation_data(
            relation_sets[relation_set_id])
        add_data_from_single_image_graph_to_cluster_graph2(
            relation_set_id, line_graph, cluster_graph)

    return cluster_graph
Пример #2
0
def setup_graph_type_1() -> nx.MultiDiGraph:
    line_data = import_data.read_relation_data()
    line_cluster = LineClustering(line_data)
    relation_sets: Dict[int,
                        ValuesView[RelationData]] = line_cluster.relation_sets

    cluster_graph: nx.MultiDiGraph = setup_base_cluster_graph(
        line_cluster.distinct_labels)

    for relation_set_id in relation_sets:
        line_graph = create_cluster_from_relation_data(
            relation_sets[relation_set_id])
        add_data_from_single_image_graph_to_cluster_graph(
            line_graph, cluster_graph)

    return cluster_graph
def create_cluster_colour_map(distinct_labels: list) -> dict:
    number_of_clusters = len(distinct_labels)
    cluster_colour_map = {}
    counter = 0
    diff = 255 / number_of_clusters

    for label in distinct_labels:
        cluster_colour_map[label] = '#%02x%02x%02x' % (int(counter), int(counter), 0)
        counter += diff

    return cluster_colour_map


if __name__ == '__main__':
    line_data = import_data.read_relation_data()

    # line_code_line_id_relation_data_map = import_data.transform_to_line_code_map(line_data)

    # The last four lines are the ones that make up a rectangle
    last_four_lines: IntegerToListOfIntegerMap = import_data.filter_out_four_last_lines_of_data(line_data)

    array_data = import_data.transform_selected_lines_to_array(line_data, last_four_lines)
    line_code_line_id_relation_data_map: LineCodeMap = extract_line_code_map_from_array(array_data)

    # data_used_for_clustering = array_data[:, 3:6]
    data_used_for_clustering = array_data[:, 5]

    # Trying with only angle to see if clusters look as expected
    # data_used_for_clustering = array_data[:, 4:6]
Пример #4
0
from import_data import import_line_data
import numpy as np
from import_data.import_data import filter_out_four_last_lines_of_data, transform_selected_lines_to_array, read_relation_data
from clustering.dbscan_clustering_test import extract_line_code_map_from_array, \
    extract_rectangle_relation_data_for_line_code, do_dbscan, add_label_data_to_line_code_map, \
    find_relation_sets_for_all_last_four_lines, create_cluster_colour_map, \
    create_line_colour_map_for_line_code

line_data = import_line_data.read_data()
line_relation_data = read_relation_data()

# The last four lines are the ones that make up a rectangle
last_four_lines = filter_out_four_last_lines_of_data(line_relation_data)

array_data = transform_selected_lines_to_array(line_relation_data,
                                               last_four_lines)
line_code_line_id_relation_data_map = extract_line_code_map_from_array(
    array_data)

data_used_for_clustering = array_data[:, 5]
dbscan_data = do_dbscan(np.reshape(data_used_for_clustering, (-1, 1)))
add_label_data_to_line_code_map(dbscan_data.labels_, array_data,
                                line_code_line_id_relation_data_map)

line_code = 89
extract_rectangle_relation_data_for_line_code(
    line_code, line_code_line_id_relation_data_map, last_four_lines)

relation_sets = find_relation_sets_for_all_last_four_lines(
    last_four_lines, line_code_line_id_relation_data_map)
for key in relation_sets: