def __init__(self, image_file_path, piece_width, puzzle_type, distance_function): # Store the information about the input image self._filename_root = Puzzle.get_filename_without_extension(image_file_path) self._file_extension = Puzzle.get_file_extension(image_file_path) # File extension should not include the period assert "." not in self._file_extension logging.info("Performing best buddy analysis for image: %s" % self._filename_root) self.puzzle_type = puzzle_type # Consider both interior and exterior best buddies. self._numb_wrong_exterior_bb = 0 self._total_numb_interior_bb = 0 self._numb_wrong_interior_bb = 0 # Build a puzzle self._puzzle = Puzzle(0, image_file_path, piece_width) self.numb_pieces = self._puzzle.numb_pieces # Get the piece IDs self._puzzle.assign_all_piece_id_numbers_to_original_id() self._puzzle.assign_all_pieces_to_original_location() self._puzzle.assign_all_pieces_to_same_rotation(PuzzlePieceRotation.degree_0) # Calculate the inter-piece distance self._interpiece_distance = InterPieceDistance(self._puzzle.pieces, distance_function, puzzle_type) # Get the link between number of test buddies and accuracy self._numb_best_buddies_versus_accuracy = np.zeros((PuzzlePieceSide.get_numb_sides() + 1, PuzzlePieceSide.get_numb_sides() + 1, PuzzlePieceSide.get_numb_sides() + 1), np.uint32) # Store the location of each piece self._piece_locations, _ = self._puzzle.build_placed_piece_info()