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