import cv2
import numpy as np
if __name__ == '__main__':
img_src = cv2.imread("picture.png", 1)
img_gray = cv2.cvtColor(img_src, cv2.COLOR_BGR2GRAY)
thresh = 100
max_pixel = 255
ret, img_dst = cv2.threshold(img_gray,
thresh,
max_pixel,
cv2.THRESH_BINARY)
color = (100,100,255)
thickness=2
cv2.rectangle(img_dst, (10,10), (200,200), color, thickness)
cv2.circle(img_dst,(400,400),50,color,thickness)
fontscale = 4.0
msg = "Hello,_OpenCV!"
cv2.putText(img_dst,msg,(300,300),cv2.FONT_HERSHEY_PLAIN,fontscale,color,thickness)
cv2.imshow("Show BINARIZATION Image", img_dst)
cv2.imwrite("picture_bin.png", img_dst)
cv2.destroyAllWindows()