#opencv学习
import cv2
import matplotlib
#matplotlib.use('agg')
import matplotlib.pyplot as plt
import numpy as np
img=cv2.imread('hblgos.jpg',cv2.IMREAD_GRAYSCALE)
#print(img)
'''cv2.imshow('picture',img)
cv2.waitKey(0)
cv2.destroyAllWindows()'''
'''cv2.imwrite('first.jpg',img=img)
print(img.shape)'''
#poi区域,只捕捉感兴趣的区域
imag=cv2.imread('hblgos.jpg')
#进行切片获得想要的部分
#now=imag[0:50,0:150]
# cv2.imshow('roi',now)
# cv2.waitKey(0)
# cv2.destroyAllWindows()
b,g,r=cv2.split(imag)
print(r.shape)
imag=cv2.merge((b,g,r))
print(imag.shape)
cp_imag=imag.copy()
cp_imag[:,:,0]=0
cp_imag[:,:,1]=1
cv2.imshow('r',cp_imag)
cv2.waitKey(0)
cv2.destroyAllWindows()
标签:img,imag,cv2,opencv,初学,print,import,cp
From: https://www.cnblogs.com/tgfoven/p/17105414.html