import cv2
import numpy as np
img = cv2.imread("qimo.jpg") # 读取原始图像
img = cv2.resize(img,(300,300))
img1 = img.copy()
cv2.putText(img1,"20040420",(40,100),cv2.FONT_HERSHEY_TRIPLEX,1,(0,0,0),3)
cv2.putText(img1,"WQ",(30,200),cv2.FONT_HERSHEY_TRIPLEX,2,(0,0,0),3)
img2 = img.copy()
cv2.circle(img2,(50,50),40,(0,0,255),-1)
r,c,s = img.shape
img3 = img.copy()
cv2.putText(img3,"%d %d %d" % (r,c,s),(40,100),cv2.FONT_HERSHEY_TRIPLEX,1,(0,0,0),3)
img4 = img.copy()
t1, img4 = cv2.threshold(img4,127,255,cv2.THRESH_BINARY)
img5 = img.copy()
img5 = cv2.bitwise_not(img5)
img6 = img.copy()
img6 = cv2.add(img6,img6)
img7 = img.copy()
img7 = cv2.resize(img7,(600,300))
gray = img.copy()
gray = cv2.resize(gray,(600,300))
gray = cv2.cvtColor(gray,cv2.COLOR_BGR2GRAY)
t2,img7 = cv2.threshold(gray,0,255,cv2.THRESH_BINARY + cv2.THRESH_OTSU)
img7 = cv2.cvtColor(img7,cv2.COLOR_GRAY2BGR)
img8 = img.copy()
for i in range(30,200,60):
img8[i:i+30] = (0,0,255)
img9 = img.copy()
img9 = cv2.GaussianBlur(img9,(5,5),0,0)
img10 = img.copy()
counters,hierachy = cv2.findContours(gray,cv2.RETR_LIST,cv2.CHAIN_APPROX_NONE)
cv2.drawContours(img10,counters,-1,(0,0,0),5)
img11 = img.copy()
gray = cv2.resize(gray,(300,300))
img11 = cv2.adaptiveThreshold(gray,255,cv2.ADAPTIVE_THRESH_MEAN_C,cv2.THRESH_BINARY,5,3)
img11 = cv2.cvtColor(img11,cv2.COLOR_GRAY2BGR)
img12 = img.copy()
img12 = cv2.morphologyEx(img12,cv2.MORPH_OPEN,(5,5))
img13 = img.copy()
img13 = cv2.flip(img13,-1)
img14 = img.copy()
M = np.float32([[1,0,0],[0,1,100]])
c,r = img.shape[0],img.shape[1]
img14 = cv2.warpAffine(img14,M,(c,r))
img15 = img.copy()
M = cv2.getRotationMatrix2D((150,150),-45,0.5)
img15 = cv2.warpAffine(img15,M,(c,r))
h1 = np.hstack((img1,img2,img3,img4))
h2 = np.hstack((img5,img6,img7))
h3 = np.hstack((img8,img9,img10,img11))
h4 = np.hstack((img12,img13,img14,img15))
v = np.vstack((h1,h2,h3,h4))
cv2.imshow("test",v)
cv2.imwrite("20040420.jpg",v)
cv2.waitKey()
qimo.jpg
attention
#有时候不能打字,ctrl+c切屏再切回来就行了
#dst12 = cv2.cvtColor(dst12,cv2.COLOR_GRAY2RGB)二维到三维
# —————————————————————————— 三个TAB 13个—— 总表达式一个Tab 中间隔三行
# 小:三个TAB 8个——