def get_bottom(blobs): closest = [] for blob in blobs: nodes = utility.convert_to_easy_array(blob.load()) closest.append(nodes[utility.closest_node((92, 92), nodes)]) return utility.closest_node((0, 184), closest)
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])
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])