python - 填充轮廓图,同时覆盖在另一个图像上
问题描述
我在显示填充轮廓时遇到问题,而过度显示在另一张图像上。目前它向我显示未填充的轮廓。任何评论将不胜感激。
plt.imshow(t_image.detach().cpu().squeeze(), cmap='gray')
plt.contourf(filter_canny_predicted, colors='red')
plt.contourf(filter_canny_mask, colors='green')
plt.autoscale()
plt.show()
根据这里的答案
我将 set_rasterized 添加到片段中,但无法弄清楚轮廓和背景图像都消失了。这是我尝试使用 rasetrized 填充轮廓时的片段
fig, (ax1) = plt.subplots(nrows=1, ncols=1, sharex=True, sharey=True)
ax1.imshow(t_image.detach().cpu().squeeze(), cmap='gray')
cs = ax1.contourf(filter_canny_predicted)
css = ax1.contourf(filter_canny_mask)
ax1.axis('on')
ax1.autoscale()
#ax1.tight_layout(pad=0.01, w_pad=0.002, h_pad=1)
for c in cs.collections:
c.set_rasterized(True)
for cc in css.collections:
cc.set_rasterized(True)
plt.show()
为了澄清一个filter_canny_predicted
是红色的,一个filter_canny_mask
是黄色的。
解决方案
推荐阅读
- rust - 从 Rust 为机器类型 wasm32 构建 LLVM
- tvos - 无法通过 Apple Configurator 2 在 Apple TV 上安装 Charles Proxy 配置文件
- c++ - 通过 F() makro 打印字符数组
- azure - 为本地环境设置 Azure Application Insights
- python - 使用 plt.savfig 在 Google Colab 上使用轴保存图形
- python-3.x - 在 Solaris 服务器上安装 Python3 的步骤
- sql - 是否有任何规则或文档可用于 Oracle 数据库选择语句的列名的输出名称?
- javascript - 当元素根本没有出现在页面上时检查元素的可见性
- python - 使用 Frappe + ERP 在桌面上添加自定义应用程序
- javascript - 将 th 的文本添加到该列中 td 中的数据属性