"Python" OpenCV3 computer Vision Library Second Play _ Simple picture processing

Source: Internet
Author: User

Note that this library is based on python2.7, so the syntax details are different from before

Cv2 and NumPy depth fit, the picture read into is Numpy.array, but dtype comparison is not used only, support all array method (nonsense ...)

Cv2.cvtcolor (Img,cv2. COLOR_BAYER_BG2BGR)

Img.item (0,0)

Img.itemset ((0,0), 0)

Cv2.imshow (' My Image ', IMG)

Cv2.waitkey ()

Cv2.destroyallwindows ()

1 #Coding=utf-82 ImportCv23 ImportNumPy as NP4 5 #Array Generation6img = Np.zeros ((3,3), dtype=np.uint8)7 PrintImg.shape8 9 #Array arrays converted to BGR modeTen #I don't know why I don't use the RGB and so crappy usage of BGB OneIMG =Cv2.cvtcolor (Img,cv2. COLOR_BAYER_BG2BGR) A PrintImg.shape -  - #read the picture, the top left pixel is rewritten in blue, save theimg = Cv2.imread ('Beauti.jpeg') -IMG[0][0] = [255, 0,0] -Cv2.imwrite ('Mypic.png', IMG) -  + #lost color information, the upper left Pixel is rewritten as black, save -img = Cv2.imread ('Beauti.jpeg', Cv2. Imread_grayscale) + PrintImg.shape AImg[0][0] =0 atCv2.imwrite ('Mypic-gray.png', IMG) -  - #use Array.item and array.itemset to gracefully rewrite the above code -img = Cv2.imread ('Beauti.jpeg', Cv2. Imread_grayscale) - PrintImg.shape - #Img[0][0] = 0 in PrintImg.item (0,0) - Img.itemset ((0,0), 0) toCv2.imwrite ('Mypic-gray.png', IMG) +  - #Remove the green channel theimg = Cv2.imread ('Beauti.jpeg') *img[:,:,1] =0 $Cv2.imwrite ('No_green.png', IMG)Panax Notoginseng PrintImg.shape,img.size,img.dtype -  theimg = Cv2.imread ('Beauti.jpeg') + #To display a picture, you must enter two parameters ACv2.imshow ('My Image', IMG) the #Window display Time + Cv2.waitkey () - #Release Window $Cv2.destroyallwindows ()

"Python" OpenCV3 computer Vision Library Second Play _ Simple picture processing

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.