简体   繁体   English

我想在 colab 中使用 cv2_imshow

[英]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.

相关问题 cv2_imshow() 不在 Google Colab 中呈现视频文件 - cv2_imshow() doesn't render video file in Google Colab TypeError: cv2_imshow() 接受 1 个位置参数,但给出了 2 个:google colab cv 相关问题 - TypeError: cv2_imshow() takes 1 positional argument but 2 were given : google colab cv related problems google colab,cv2_imshow 抛出错误:'NoneType' object 没有属性'clip' - google colab, cv2_imshow throws error: 'NoneType' object has no attribute 'clip' 我想在 colab 中使用 imshow(),但它不起作用 - I want to use imshow() in colab, but it doesn't work 'NoneType' object has no attribute 'clip' error in ```cv2_imshow()``` - 'NoneType' object has no attribute 'clip' error in ```cv2_imshow()``` plt.imshow() 绘制的图像是倒置的,而 cv2_imshow() 绘制的图像很好,我怎么知道我的 neural.net 得到了什么? - Image plotted by plt.imshow() is inverted while same image by cv2_imshow() is fine, how do I know what my neural net gets? cv2.imshow 并在 colab 中写入视频帧 - cv2.imshow and write video frames in colab google colab kernel 崩溃:cv.imshow('img',img) cv.waitKey(0) cv.destroyAllWindows() - google colab kernel crashes: cv.imshow('img',img) cv.waitKey(0) cv.destroyAllWindows() 尝试使用cv2.imshow时出错 - error trying to use cv2.imshow 我可以使用哪个宏定义来检查我的 OpenCV 库是否支持 cv::imshow 接口? - Which macro definition could I use to check if my OpenCV lib support the cv::imshow interface?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM