zoukankan      html  css  js  c++  java
  • numpy计算

    import numpy as np
    import cv2
    from PIL import Image
    #lenna.jpg
    # Create a black image
    #img=np.zeros((512,512,3), np.uint8)
    
    #Python-opencv划线/画圆/椭圆/添加文字 - CSDN博客 https://blog.csdn.net/gan_player/article/details/78332152
    #python+opencv图像金字塔融合 (超详细讲解原理及代码讲解) http://www.360doc.com/content/17/0912/21/10408243_686609527.shtml
    imgname='lenna.jpg'
    img=cv2.imread(imgname)
    w,h =img.shape[1], img.shape[0]
    
    # resize_factor=1.2
    # mid_icon_w, mid_icon_h=int(w*resize_factor),int(h*resize_factor)
    # img=img.resize((mid_icon_w, mid_icon_h), Image.ANTIALIAS)
    imgname2='qq.JPG'
    img2=cv2.imread(imgname2)
    w2,h2 =img2.shape[1], img2.shape[0]
    
    rows, cols, channels = img2.shape
    
    img[10:10+rows,10:10+cols] = img2  # 把添加了logo的该区域赋值回原来的地方
    
    
    #mid_icon_w,mid_icon_h=1024,1024
    # img=img.resize((mid_icon_w, mid_icon_h), Image.ANTIALIAS)
    # Draw a diagonal blue line with thickness of 5 px
    #cv2.line(img,(0,0),(511,511),(255,0,0),5)
    
    #draw rectangle
    #cv2.rectangle(img,(384,0),(510,128),(0,255,0),3)
    
    #draw circle
    
    step,r_=80,50
    
    #cv2.circle(img,(50,63), 63, (0,0,255), -1)
    
    # circle(img, center, radius, color, thickness=None, lineType=None, shift=None)
    for i in range(5):
        img=cv2.circle(img, ((i+1)*step, (i+1)*step), r_, (0, 0, 255), -1)
    
    #draw ellipse
    #cv2.ellipse(img,(256,256),(100,50),30,0,360,255,3)
    
    #draw multi-lines
    #pts=np.array([[10,5],[20,30],[70,20],[50,10]], np.int32)
    #pts=pts.reshape((-1,1,2))
    #cv2.polylines(img,[pts],True,(0,0,255),3)#如果去掉中括号,只是画四个点
    
    #add words
    font=cv2.FONT_HERSHEY_SIMPLEX
    cv2.putText(img,'OpenCV',(10,500), font, 4,(255,255,255),2)
    
    cv2.imshow('opencv',img)
    cv2.imwrite('C:\imageVideo\my.jpg',img)
    
    cv2.waitKey(0)
    cv2.destroyAllWindows()
    cv2.waitKey(1)
    cv2.waitKey(1)
    cv2.waitKey(1)
    cv2.waitKey(1)
    
    d=9
    

      

  • 相关阅读:
    2019.8.15刷题统计
    2019.8.12刷题统计
    2019.8.11刷题统计
    2019.8.10刷题统计
    2019.8.9刷题统计
    2019.8.8刷题统计
    2019.8.7刷题统计
    2019.8.6刷题统计
    xuezhan.org 6.28
    xuezhan.org 6.27
  • 原文地址:https://www.cnblogs.com/rsapaper/p/9273207.html
Copyright © 2011-2022 走看看