1.读取图片
这里要注意的是路径不能出现中文
import cv2
img=cv2.imread(r'D:\tupian\build.jpg',1)
cv2.imshow('img',img)
cv2.waitKey(0)
for i in range(1,100):
img[i,i]=(255,0,0)
cv2.imshow('img1',img)
cv2.waitKey(0)
3.图片缩放
dst=cv2.resize(img,(0,0),fx=0.4,fy=0.4)
cv2.imshow("dst",dst)
cv2.waitKey(0)
dst1=img[10:500,10:300]
cv2.imshow("剪切",dst1)
cv2.waitKey(0)
shape=img.shape
print(shape)
h=shape[0]
w=shape[1]
mxz=cv2.getRotationMatrix2D((w*0.5,h*0.5),45,0.5)
xz=cv2.warpAffine(img,mxz,(w,h))
cv2.imshow('xz',xz)
cv2.waitKey(0)
hui=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
cv2.imshow('hui',hui)
cv2.waitKey(0)