import numpy as np import cv2 import math print("version openCV:"+str( cv2.__version__ )) img = cv2.imread('img.jpg') print(img) print(type(img)) print(img.shape) print(img[637][633][:]) img[637][633][0]= 255 img[637][633][1]= 0 img[637][633][2]= 0 haut=60 larg=60 v0=264 u0=700 ball = img[v0:v0+haut, u0:u0+larg] for n in range(3): v1=224 u1=442 img[v1:v1+haut, n*100+u1:n*100+u1+larg] = ball cv2.line(img,(0,0),(511,511),(255,0,0),1,cv2.LINE_AA) hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV) # define range of blue color in HSV lower_green = np.array([35,0,0]) upper_green = np.array([85,255,255]) # Threshold the HSV image to get only blue colors mask = cv2.inRange(hsv, lower_green, upper_green) # Bitwise-AND mask and original image res = cv2.bitwise_and(img,img, mask= mask) for m in range(256): for n in range(256): img[n][m][0]= m img[n][m][1]= 0 img[n][m][2]= n for m in range(img.shape[1]): for n in range(img.shape[0]): g=(m%2)*255 img[n][m][0]= g img[n][m][1]= g img[n][m][2]= g #cv2.line(img,(0,0),(511,511),(255,0,0),1,cv2.LINE_4) font = cv2.FONT_HERSHEY_SIMPLEX cv2.putText(img,'OpenCV',(10,500), font, 4,(255,255,255),2,cv2.LINE_AA) flags = [i for i in dir(cv2) if i.startswith('COLOR_')] print(flags) ''' Enumerator FILLED Python: cv.FILLED LINE_4 Python: cv.LINE_4 4-connected line LINE_8 Python: cv.LINE_8 8-connected line LINE_AA Python: cv.LINE_AA antialiased line ''' #cv2.imshow('image',img) cv2.imshow('image',res) cv2.waitKey(0) cv2.destroyAllWindows() #cv2.imwrite('imggray.png',img) #cv2.imwrite('imggray.jpg',img)#cv2.imwrite('imggray.jpg',img) cv2.imwrite('imgcolor.png',img)