python opencv

##cv2.imshow('img',img)
##cv2.waitKey(0)
##cv2.destroyAllWindows()
#
##cv2.namedWindow('image',cv2.WINDOW_NORMAL)
##cv2.imshow('image',img)
##cv2.waitKey(0)
##cv2.destroyAllWindows()
#
##plt.imshow(img, cmap = 'gray', interpolation = 'bicubic')
##plt.xticks([]), plt.yticks([])# to hide tick values on X and Y axis
##plt.show()                
#                
#                
##cap = cv2.VideoCapture(0)                
##                
##while(True):
##    #Capture frame-by-frame
##    ret,frame = cap.read()
##    #Our operations on the frame come here            
##    gray = cv2.cvtColor(frame,cv2.COLOR_RGB2GRAY)
##     
##    #Display the resulting frame
##    cv2.imshow('frame',gray)
##    if cv2.waitKey(1) & 0xFF == ord('q'):
##        break
##
##cap.release()
##cv2.destroyAllWindows()
##                

##img = np.zeros((512,512,3), np.uint8)
#
##img = cv2.line(img,(0,0),(511,511),(255,0,0),5)     
##img = cv2.rectangle(img,(384,0),(510,128),(0,255,0),3)
##img = cv2.circle(img,(447,63), 63, (0,0,255), -1)
##img = cv2.ellipse(img,(256,256),(100,50),0,0,180,255,-1)  
##pts = np.array([[10,5],[20,30],[70,20],[50,10]], np.int32)
##pts = pts.reshape((-1,1,2))
##img = cv2.polylines(img,[pts],True,(0,255,255)) 
#
##cv2.imshow('img',img)     
##cv2.waitKey(0)
##cv2.destroyAllWindows()
#                
##events = [i for i in dir(cv2) if 'EVENT' in i]         
##print (events) 
#
## 
##def draw_circle(event,x,y,flags,param):
##    if event == cv2.EVENT_LBUTTONDBLCLK:
##        cv2.circle(img,(x,y),100,(255,0,0),-1)
##        
### Create a black image, a window and bind the function to window
##img = np.zeros((512,512,3), np.uint8)
##cv2.namedWindow('image')
##cv2.setMouseCallback('image',draw_circle)
##
##while(1):
##    cv2.imshow('image',img)
##    if cv2.waitKey(20) & 0xFF ==27 :
##        break
##cv2.destroyAllWindows()
#
#
##drawing = False
##mode = True 
##ix,iy =-1,-1
##
##def draw_circle(event,x,y,flags,param):
##    global ix,iy,drawing,mode
##    
##    if event == cv2.EVENT_LBUTTONDOWN:
##        drawing = True
##        ix,iy =x,y
##    elif event == cv2.EVENT_MOUSEMOVE:
##        if drawing == True:
##            if mode ==True:
##                cv2.rectangle(img,(ix,iy),(x,y),(0,255,0),-1)
##            else:
##                cv2.circle(img,(x,y),5,(0,0,255),-1)
##    elif event ==cv2.EVENT_LBUTTONUP:
##        drawing = False
##        if mode == True:
##            cv2.rectangle(img,(ix,iy),(x,y),(0,255,0),-1)
##        else:
##            cv2.circle(img,(x,y),5,(0,0,255),-1)
##
##
##img = np.zeros((512,512,3), np.uint8)
##cv2.namedWindow('image')
##cv2.setMouseCallback('image',draw_circle)
##while(1):
##    cv2.imshow('image',img)
##    k = cv2.waitKey(1) & 0xFF
##    if k == ord('m'):
##        mode = not mode
##    elif k == 27:
##        break
##    
##cv2.destroyAllWindows()
##        
##    
#
##   
##def nothing(x):
##    pass
##
###Create a black image, a window
##img = np.zeros((300,512,3), np.uint8)
##cv2.namedWindow('image')
#
## create trackbars for color change
#
#cv2.createTrackbar('R','image',0,255,nothing)
#cv2.createTrackbar('G','image',0,255,nothing)
#cv2.createTrackbar('B','image',0,255,nothing)
### create switch for ON/OFF functionality
##switch = '0 : OFF \n1 : ON'
##cv2.createTrackbar(switch, 'image',0,1,nothing)
##
##while(1):
##    cv2.imshow('image',img)
##    k = cv2.waitKey(1) & 0xFF
##    if k == 27:
##        break
##    
##    # get current positions of four trackbars
##    
##    r = cv2.getTrackbarPos('R','image')
##    g = cv2.getTrackbarPos('G','image')
##    b = cv2.getTrackbarPos('B','image')
##    s = cv2.getTrackbarPos(switch,'image')
##    
##    if s == 0:
##        img[:] = 0
##    else:
##        img[:] = [b,g,r]
##cv2.destroyAllWindows()
##           




#px = img[100,100]
#print (px)
#
#blue =  img[100,100,0]
#print (blue)
#img [100,100] = [255,255,255]
#print (img[100,100])
#img.item(10,10,2)
#
#print(img.shape)
#print(img.size)
#print(img.dtype)
#








b,g,r = cv2.split(img)
img = cv2.merge((b,g,r))

猜你喜欢

转载自blog.csdn.net/qq_41858768/article/details/80041547
今日推荐