# upscale the rough homography matrix logger.info("Inverting homography...") if method=='Projective': Rough_Homography_Upscaled=Rough_Homography_Downscaled*scale_matrix homography_inverse=np.linalg.inv(Rough_Homography_Upscaled) else: Rough_Homography_Upscaled=Rough_Homography_Downscaled homography_inverse=cv2.invertAffineTransform(Rough_Homography_Downscaled) # Initialize the output file bw = BioWriter(str(Path(outDir).joinpath(Path(registration_set[1]).name)),metadata=br_mov.read_metadata(),max_workers=write_workers) bw.num_x(br_ref.num_x()) bw.num_y(br_ref.num_y()) bw.num_z(1) bw.num_c(1) bw.num_t(1) # transformation variables reg_shape = [] reg_tiles = [] reg_homography = [] # Loop through image tiles and start threads logger.info("Starting threads...") threads = [] first_tile = True with ThreadPoolExecutor(max_workers=loop_workers) as executor: for x in range(0,br_ref.num_x(),2048): for y in range(0,br_ref.num_y(),2048):
if len(paths) == 0: continue # Initialize the output file br = BioReader(paths[0]['file']) file_name = filepattern.output_name( filePattern, paths, {c: paths[0][c] for c in fp.variables if c != 'c'}) logger.info('Writing: {}'.format(file_name)) bw = BioWriter(str(Path(outDir).joinpath(file_name)), metadata=br.read_metadata()) del br # Modify the metadata to make sure channels are written correctly bw.num_c(len(paths)) bw._metadata.image().Pixels.channel_count = bw.num_c() # Process the data in tiles threads = [] count = 0 total = bw.num_c() * bw.num_z() * \ (bw.num_x()//chunk_size + 1) * (bw.num_y()//chunk_size + 1) with ThreadPoolExecutor(cpu_count()) as executor: for c, file in enumerate(paths): br = BioReader(file['file']) C = [c] first_image = True for z in range(br.num_z()): Z = [z, z + 1] for x in range(0, br.num_x(), chunk_size):