#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2024/6/13 0013 下午 12:57 # @Author : liudan # @File : read.py # @Software: pycharm import cv2 import numpy as np # 图片路径 image1_path = './data/demo_613/ref_image/ADSC_0478.JPG' image2_path = './data/demo_613/1_regis_result/wrap_image_ADSC_0478.JPG.jpg' # 读取图片 image1 = cv2.imread(image1_path) image2 = cv2.imread(image2_path) # 检查图片是否成功读取 if image1 is None or image2 is None: print("Error: Could not load images.") else: # 对图片进行处理,这里只是简单地将它们转换为灰度图 gray_image1 = cv2.cvtColor(image1, cv2.COLOR_BGR2GRAY) gray_image2 = cv2.cvtColor(image2, cv2.COLOR_BGR2GRAY) # 保存处理后的图片 cv2.imwrite('gray_image1.jpg', gray_image1) cv2.imwrite('gray_image2.jpg', gray_image2) print("Images have been successfully read and saved.")