low += step thread = UpdateSuperPixelThread(low, hi, threads_num) thread.start() threads.append(thread) # 多线程等待结束 for t in threads: t.join() src_img.as_unit().cvt_GRAY() ref_img.as_unit().cvt_BGR() return res_img.as_unit().cvt_BGR() if __name__ == '__main__': root_path = pu.get_root_path() src_img = ImageController(pu.path_join(root_path, pu.INPUT_PATH, SRC_IMG), clr="GRAY") ref_img = ImageController(pu.path_join(root_path, pu.INPUT_PATH, REF_IMG)) res_img = gray_trans_superpixel(src_img, ref_img) iu.print_imgs(src_img, ref_img, res_img) iu.save_img( res_img.ndarray, pu.path_join( root_path, pu.OUTPUT_PATH, f"gray_trans/superpixel/coast/res_img" f"_{w[0][0]}" f"_{w[1][0]}" f"_{ SRC_SUPERPIXEL_NUM }" f"_{ REF_SUPERPIXEL_NUM }.png"))
import cv2 from src.image_control.core.control import ImageController from src.math_utils.core.matrix import Matrix from src.common_utils.core.path_utils import INPUT_PATH, OUTPUT_PATH, get_root_path, path_join if __name__ == '__main__': # 获取图像 SRC_IMG = path_join("reinhard", "sea", "day.png") REF_IMG = path_join("reinhard", "sea", "night.png") root_path = get_root_path() src_ic = ImageController(file=path_join(root_path, INPUT_PATH, SRC_IMG)) ref_ic = ImageController(file=path_join(root_path, INPUT_PATH, REF_IMG)) a = Matrix.conv2(src_ic.cvt_GRAY(), Matrix.SOBEL_KERNEL_X) cv2.imshow("conv2", a) cv2.waitKey() cv2.destroyAllWindows()