[英]I want to use cv2_imshow in colab
import cv2 as cv import numpy as np from google.colab.patches import cv2_imshow from tensorflow.keras.models import load_model img_color = cv.imread('test3.jpg', cv.IMREAD_COLOR) img_gray = cv.cvtColor(img_color, cv.COLOR_BGR2GRAY) ret,img_binary = cv.threshold(img_gray, 0, 255, cv.THRESH_BINARY_INV | cv.THRESH_OTSU) kernel = cv.getStructuringElement( cv.MORPH_RECT, ( 5, 5 ) ) img_binary = cv.morphologyEx(img_binary, cv. MORPH_CLOSE, kernel) cv2_imshow('digit', img_binary) cv.waitKey(0)
This is the process of training a model in handwritten and testing the trained model.这是以手写方式训练模型并测试训练模型的过程。 I want to load an image using imshow() in colab.我想在 colab 中使用 imshow() 加载图像。
Is there any way to use it without setting the file path?有没有办法在不设置文件路径的情况下使用它?
You can use matplotlib's function for it您可以使用matplotlib 的功能
fig = plt.gcf()
fig.set_size_inches(18, 10)
plt.axis("off")
plt.rcParams['figure.figsize'] = [20, 10]
plt.imshow(img_binary)
plt.show()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.