zoukankan      html  css  js  c++  java
  • python opencv 学习笔记

    图片缩放

      image=cv2.imread('test.jpg')
      res=cv2.resize(image,(32,32),interpolation=cv2.INTER_CUBIC)
      cv2.imshow('iker',res)
      cv2.imshow('image',image)
      cv2.waitKey(0)
      cv2.destoryAllWindows()

    OpenCV与Python之图像的读入与显示以及利用Numpy的图像转换

    mxnet图像转换为opencv的类型,保存

        img = mx.image.imdecode(s).asnumpy() 
        # plt.imshow(img)
        # plt.title('id=' + str(i) + 'label=' + str(header.label))
        # plt.savefig("mxshow/label_" + str(header.label) + '_id_' + str(i) + ".jpg")
        # plt.pause(1)
        label = str(header.label)
        label = label.strip().split(".")[0]
        print("all num " + str(all) + " current index "+str(i)+" process "+str(i  * 100.0 / all)+"%")
        label_dir = os.path.join(decode_path, label)
        if not os.path.isdir(label_dir):  # Create the log directory if it doesn't exist
        	label_num += 1
        	os.makedirs(label_dir)
        X = img
        print(X.shape)
        X = cv2.cvtColor(X, cv2.COLOR_RGB2BGR)
        X = cv2.resize(X,(160,160), interpolation=cv2.INTER_CUBIC)
        cv2.imwrite(label_dir + "/label_" + str(label) + '_id_' + str(i) + ".jpg", X)
    

      

  • 相关阅读:
    2018CodeM复赛
    poj3683
    bzoj3991
    bzoj2809
    bzoj1001
    bzoj1412
    计蒜之道2018复赛
    HDU2255
    bzoj1010
    bzoj2006
  • 原文地址:https://www.cnblogs.com/adong7639/p/9009637.html
Copyright © 2011-2022 走看看