Python opencv3 using NumPy to access image data

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.