read.py 944 B

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