1 #Coding:utf82 ImportCv23 4 """5 Change BGR at (0, 0) to white pixels6 7 No. 0, Green 1th, Blue 2nd, Red8 Each of the IMG locations has a 3-length vector representing the GBR9 """Ten #img = Cv2.imread (".. /data/mm2.jpeg ") One #print (img[0, 0]) # [+] A #img[0, 0] = [255, 255, 255] - #cv2.imshow ("", IMG) - #cv2.waitkey (0) the - - """ - change the blue value of coordinates (150, 120) to 255 + - It is recommended to use the Itemset function, which avoids access to the original index + """ A #img = Cv2.imread (".. /data/mm2.jpeg ") at #Print (Img.item (150, 120, 0)) # Prints the blue value of this coordinate - #cv2.imshow ("", IMG) - #Img.itemset ((150, 120, 0), 255) # Set the blue value of this position to 255 - #Print (Img.item (150, 120, 0)) # Prints the blue value of this coordinate - - in """ - set all green values of the image to 0 to + using loops is not recommended, and using indexes can improve the efficiency of program implementation. - """ the #img = Cv2.imread (".. /data/mm1.jpg ") * #img[:,:, 1] = 0 $ #cv2.imshow ("", IMG)Panax Notoginseng #cv2.waitkey (0) - the + """ A bind an area to a variable and assign a value to the second region the """ + #img = Cv2.imread (".. /data/mm3.jpg ") - #My_roi = img[0:100, 0:100] # Select width and height are 0 to 100 area for area of interest $ #img[300:400, 300:400] = My_roi # Assigns the value of the My_roi area and the position of 300 to 400 pixels $ #cv2.imshow ("", IMG) - #Cv2.waitkey () - the """ - view some properties of an imageWuyi shape: Width height and number of channels the Size: Dimensions of image pixels - datatype: The data type of the image is generally unsigned integer Wu """ -img = Cv2.imread (".. /data/mm3.jpg") About Print(Img.shape)#(+, 3) $ Print(img.size)#2250000 - Print(Img.dtype)#uint8
Python opencv3 using NumPy to access image data