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)