import cv2
import numpy as np
img = cv2.imread('image0.jpg',1)
font = cv2.FONT_HERSHEY_SIMPLEX
cv2.rectangle(img,(500,400),(200,100),(0,255,0),20)
# 1 dst 2 文字内容 3 坐标 4 5 字体大小 6 color 7 粗细 8 line type
cv2.putText(img,'flower',(200,50),font,1,(0,0,250),2,cv2.LINE_AA)
# cv2.imshow('src',img)
# cv2.waitKey(0)
array([[[ 34, 36, 30],
[ 33, 35, 29],
[ 31, 33, 27],
...,
[ 83, 110, 60],
[ 85, 110, 60],
[ 85, 110, 60]],
[[ 32, 34, 28],
[ 31, 33, 27],
[ 30, 32, 26],
...,
[ 80, 107, 57],
[ 81, 106, 56],
[ 81, 106, 56]],
[[ 31, 33, 27],
[ 31, 33, 27],
[ 30, 32, 26],
...,
[ 78, 107, 57],
[ 77, 104, 54],
[ 77, 104, 54]],
...,
[[ 14, 16, 17],
[ 11, 16, 15],
[ 15, 18, 16],
...,
[ 16, 16, 16],
[ 9, 11, 11],
[ 10, 12, 12]],
[[ 12, 16, 17],
[ 11, 16, 15],
[ 15, 19, 14],
...,
[ 16, 16, 16],
[ 14, 16, 16],
[ 15, 17, 17]],
[[ 12, 16, 17],
[ 11, 16, 15],
[ 15, 19, 14],
...,
[ 16, 16, 16],
[ 17, 19, 19],
[ 17, 19, 19]]], dtype=uint8)
import matplotlib.pyplot as plt
%matplotlib inline
dst = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
plt.imshow(dst)
plt.show()
图片绘制
import cv2
img = cv2.imread('image0.jpg',1)
height = int(img.shape[0]*0.2)
width = int(img.shape[1]*0.2)
imgResize = cv2.resize(img,(width,height))
for i in range(0,height):
for j in range(0,width):
img[i+200,j+350] = imgResize[i,j]
# cv2.imshow('src',img)
# cv2.waitKey(0)
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
plt.imshow(img)
plt.show()