Home >Backend Development >Python Tutorial >Detailed explanation of examples of using opencv to read images in python

Detailed explanation of examples of using opencv to read images in python

巴扎黑
巴扎黑Original
2018-05-19 15:45:583288browse

The following editor will bring you an example of using python to read images using opencv. The editor thinks it’s pretty good, so I’ll share it with you now and give it as a reference. Let’s follow the editor and take a look.

After installing the environment, I started the first Hello word example, how to read pictures and save pictures

import cv2 
import numpy as np 
import matplotlib.pyplot as plt 
 
#读取图片代码 
img = cv2.imread('test.jpg',cv2.IMREAD_GRAYSCALE) 
#IMREAD_COLOR = 1 
#IMREAD_UNCHANGED = -1 
#展示图片 
cv2.imshow('image',img) 
cv2.waitKey(0) 
cv2.destroyAllWindows() 
#使用matplotlib分析图片 
#plt.imshow(img,cmap='gray',interpolation='bicubic') 
#plt.plot([50,100],[80,100],'c',linewidth=5) 
#plt.show() 
#把图片保存为png格式的灰色文件。 
cv2.imwrite('testgray.png',img)

The above is the detailed content of Detailed explanation of examples of using opencv to read images in python. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn