博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ptyhon_opencv 图像的基本操作
阅读量:4626 次
发布时间:2019-06-09

本文共 1179 字,大约阅读时间需要 3 分钟。

1、cv2.imread()  to read an image
     cv2.IMREAD_COLOR:  load a color image
     cv2.IMREAD_GRAYSCALE: loads image in grayscale mode
     cv2.IMREAD_UNCHANGED: Loads image as such including alpha channel
  
下面是读一幅图像和显示一幅图像,cv.waitKey() is a keyboard function. Its argument is the time in milliseconds, 里面的参数也可能是一个具体的字母。 cv.destroyAllWindows() simply destroys all the windows.
cv.destroyWindow() where you pass the exact window name as the argument.
 
#encoding=utf-8import cv2 as cvimport numpy as np#Load an color image in grayscaleimg=cv.imread('C:\Users\Administrator\Desktop\lena.jpg',0)#imshow an imagecv.imshow('img',img)cv.waitKey(0)#这里要注意字母大小写的问题cv.destoryAllWindows()

2、下面是定义一个窗口的名字,并在窗口中显示图像,其中cv.WINDOW_AUTOSIZE()默认显示图像的大小,cv.WINDOW_NORMAL()可以根据图像的大小自动调节窗口的大小。

import cv2 as cvimport numpy as npimg=cv.imread('C:\Users\Administrator\Desktop\lena.jpg',0)cv.namedWindow('image',cv.WINDOW_NORMAL)cv.imshow('image',img)cv.waitKey(0)cv.destroyAllWindows()

3、Use the function cv.imwrite()   to save an image.  First argument is the file name,secong argument is the image you want to save.s

cv.imwrite('C:\Users\Administrator\Desktop\lena.jpg',img)

 

转载于:https://www.cnblogs.com/qducn/p/6278263.html

你可能感兴趣的文章
vim - manual -个人笔记
查看>>
详解Javascript中prototype属性(推荐)
查看>>
angularjs实现首页轮播图
查看>>
Git 对象 和checkout 和stash的笔记
查看>>
团队项目总结2-服务器通信模型和顺序图
查看>>
hdu 1085 Holding Bin-Laden Captive!
查看>>
[周记]8.7~8.16
查看>>
递归定义
查看>>
kindeditor 代码高亮设置
查看>>
图的邻接表存储
查看>>
2018 leetcode
查看>>
PHP中获取当前页面的完整URL
查看>>
Chapter 4 Syntax Analysis
查看>>
vi/vim使用
查看>>
讨论Spring整合Mybatis时一级缓存失效得问题
查看>>
Maven私服配置Setting和Pom文件
查看>>
Xcode10 library not found for -lstdc++ 找不到问题
查看>>
Mysql 8.0.13如何重置密码
查看>>
发布功能完成
查看>>
excel 合并单元格
查看>>