import numpy as np import cv2 import math print("version openCV:"+str( cv2.__version__ )) # Load an color image in grayscale img = cv2.imread('img.jpg',0) print(img) # Create a black image #img = np.zeros((512,512,3), np.uint8) #pour une image couleur #cv2.line(img,(0,0),(511,511),(255,0,0),5) cv2.line(img,(0,0),(511,511),128,5) font = cv2.FONT_HERSHEY_SIMPLEX cv2.putText(img,'BUT3',(10,500), font, 4,255,2,cv2.LINE_AA) cv2.imwrite('imggray.png',img) #--------------------------------- # Load an color image in color img = cv2.imread('img.jpg',1) print(img) cv2.imwrite('imgcolor.png',img) px = img[100,100] print("px:" + str(px)) blue = img[100,100,0] print("blue:" +str(blue)) print("image shape: " +str(img.shape)+" , image type:" +str(img.dtype)) yo=257 xo=695 larg=60 haut=60 ROI=img[yo:yo+haut, xo:xo+larg] x1=435 y1=220 img[y1:y1+haut, x1:x1+larg] = ROI for i in range(0,3): x1=435+i*120 y1=220 img[y1:y1+haut, x1:x1+larg] = ROI cv2.imshow('image',img) cv2.waitKey(0) cv2.destroyAllWindows()