Ejemplo n.º 1
0
def fill_delta(source, compare):

    source_count = algorithm.fill_ratio(source)
    compare_count = algorithm.fill_ratio(compare)

    if source_count < compare_count and (compare_count - source_count) > 1500:
        return 'added'
    elif source_count > compare_count and (source_count - compare_count) > 1500:
        return 'removed'
    else:
        return 'unchanged'
Ejemplo n.º 2
0
def compare_rows_or_cols(scores, init_set, solution_set, solutions):

    abc_pixel_count = algorithm.fill_ratio(init_set[0]) + algorithm.fill_ratio(init_set[1]) \
                      + algorithm.fill_ratio(init_set[2])

    abc_shape_count = algorithm.find_regions(init_set[0]) + algorithm.find_regions(init_set[1]) \
                        + algorithm.find_regions(init_set[2])

    gh_pixel_count = algorithm.fill_ratio(
        solution_set[0]) + algorithm.fill_ratio(solution_set[1])
    gh_shape_count = algorithm.find_regions(
        solution_set[0]) + algorithm.find_regions(solution_set[1])

    possible_answers = []
    for i, score in enumerate(scores):
        if score != 0.0:
            possible_answers.append((i, solutions[i]))

    comparisons = []
    for answer in possible_answers:
        x = (gh_pixel_count + algorithm.fill_ratio(answer[1]),
             len(gh_shape_count) + len(algorithm.find_regions(answer[1])))
        comparisons.append(x)

    x = (abc_pixel_count, len(abc_shape_count))

    closest = utility.closest_node(x, comparisons)

    return (possible_answers[closest][0], possible_answers[closest][1])
Ejemplo n.º 3
0
def compare_rows_or_cols(scores, init_set, solution_set, solutions):

    abc_pixel_count = algorithm.fill_ratio(init_set[0]) + algorithm.fill_ratio(init_set[1]) \
                      + algorithm.fill_ratio(init_set[2])

    abc_shape_count = algorithm.find_regions(init_set[0]) + algorithm.find_regions(init_set[1]) \
                        + algorithm.find_regions(init_set[2])

    gh_pixel_count = algorithm.fill_ratio(solution_set[0]) + algorithm.fill_ratio(solution_set[1])
    gh_shape_count = algorithm.find_regions(solution_set[0]) + algorithm.find_regions(solution_set[1])

    possible_answers = []
    for i, score in enumerate(scores):
        if score != 0.0:
            possible_answers.append( (i, solutions[i]))

    comparisons = []
    for answer in possible_answers:
        x = (gh_pixel_count + algorithm.fill_ratio(answer[1]), len(gh_shape_count) + len(algorithm.find_regions(answer[1])) )
        comparisons.append(x)

    x = (abc_pixel_count, len(abc_shape_count))

    closest = utility.closest_node(x, comparisons)

    return (possible_answers[closest][0], possible_answers[closest][1])