def compare_top_bottom(scores, figures, solutions, problem): if not scores: scores = [.125, .125, .125, .125, .125, .125, .125, .125] g_blobs = algorithm.get_blobs(algorithm.find_regions(figures[6])) h_blobs = algorithm.get_blobs(algorithm.find_regions(figures[7])) top_g = g_blobs[algorithm.get_top(g_blobs)] bottom_h = h_blobs[algorithm.get_bottom(h_blobs)] possible_answers = [] for i, score in enumerate(scores): if score != 0.0: possible_answers.append((i, solutions[i])) comparisons = [] for answer in possible_answers: solution_blobs = algorithm.get_blobs(algorithm.find_regions(answer[1])) top_solution = solution_blobs[algorithm.get_top(solution_blobs)] bottom_solution = solution_blobs[algorithm.get_bottom(solution_blobs)] x = (answer[0], algorithm.calc_rms(top_g, top_solution) + algorithm.calc_rms(bottom_h, bottom_solution)) comparisons.append(x) m = min(comparisons, key=lambda t: t[1]) return m
def compare_top_bottom(scores, figures, solutions, problem): if not scores: scores = [.125, .125, .125, .125, .125, .125, .125, .125] g_blobs = algorithm.get_blobs(algorithm.find_regions(figures[6])) h_blobs = algorithm.get_blobs(algorithm.find_regions(figures[7])) top_g = g_blobs[algorithm.get_top(g_blobs)] bottom_h = h_blobs[algorithm.get_bottom(h_blobs)] possible_answers = [] for i, score in enumerate(scores): if score != 0.0: possible_answers.append( (i, solutions[i])) comparisons = [] for answer in possible_answers: solution_blobs = algorithm.get_blobs(algorithm.find_regions(answer[1])) top_solution = solution_blobs[algorithm.get_top(solution_blobs)] bottom_solution = solution_blobs[algorithm.get_bottom(solution_blobs)] x = ( answer[0], algorithm.calc_rms(top_g, top_solution) + algorithm.calc_rms(bottom_h, bottom_solution)) comparisons.append(x) m = min(comparisons, key=lambda t: t[1]) return m
def compare_bottom_bc_ef(figures): b_blobs = algorithm.get_blobs(algorithm.find_regions(figures[1])) c_blobs = algorithm.get_blobs(algorithm.find_regions(figures[2])) e_blobs = algorithm.get_blobs(algorithm.find_regions(figures[4])) f_blobs = algorithm.get_blobs(algorithm.find_regions(figures[5])) if len(b_blobs) < 2 or len(c_blobs) < 2 or len(e_blobs) < 2 or len(f_blobs) < 2: return False if transformation.strict_equality(b_blobs[algorithm.get_bottom(b_blobs)], c_blobs[algorithm.get_bottom(c_blobs)]) \ and transformation.strict_equality(e_blobs[algorithm.get_bottom(e_blobs)], f_blobs[algorithm.get_bottom(f_blobs)]): return True else: return False
def compare_bottom_bc_ef(figures): b_blobs = algorithm.get_blobs(algorithm.find_regions(figures[1])) c_blobs = algorithm.get_blobs(algorithm.find_regions(figures[2])) e_blobs = algorithm.get_blobs(algorithm.find_regions(figures[4])) f_blobs = algorithm.get_blobs(algorithm.find_regions(figures[5])) if len(b_blobs) < 2 or len(c_blobs) < 2 or len(e_blobs) < 2 or len( f_blobs) < 2: return False if transformation.strict_equality(b_blobs[algorithm.get_bottom(b_blobs)], c_blobs[algorithm.get_bottom(c_blobs)]) \ and transformation.strict_equality(e_blobs[algorithm.get_bottom(e_blobs)], f_blobs[algorithm.get_bottom(f_blobs)]): return True else: return False