git: https://github.com/linyi0604/Computer-Vision

# coding:utf8
import cv2


# 读取一张图片, 第二个参数可选
image = cv2.imread("../data/mm1.jpg")
# 设置窗口
cv2.namedWindow("show", cv2.WINDOW_AUTOSIZE)
# 图像窗口显示
cv2.imshow("show", image)
# 等待按键
cv2.waitKey(0)


'''
cv2.IMREAD_ANYCOLOR = 4
cv2.IMREAD_ANYDEPTH = 2
cv2.IMREAD_COLOT = 1
cv2.IMREAD_GRAYSCALE = 0
cv2.IMREAD_LOAD_GDAL = 8
cv2.IMREAD_UNCHANGED = -1
'''

# 加载一个图像为灰度图像(会丢失颜色) 再保存为png
image = cv2.imread("../data/mm1.jpg", cv2.IMREAD_GRAYSCALE)
# 保存图片 根据拓展名自动转换保存格式 保存一定是BGR图像
cv2.imwrite("mm1_gray.png", image)

 

相关文章:

  • 2021-07-18
  • 2021-08-01
  • 2021-10-01
  • 2021-04-20
  • 2021-06-07
  • 2022-01-14
  • 2021-08-14
  • 2021-12-03
猜你喜欢
  • 2021-10-25
  • 2022-02-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-23
相关资源
相似解决方案