Skip to main content
 首页 » 编程设计

Python:将图像显示为后台进程

2025年05月04日10lonelyxmas

我正在使用 scikit-image,下面显示了我在 ipython 控制台中所做的事情:

import skimage.io as io 
import skimage.viewer.viewers.core as sv 
im = io.imread('image.jpg') 
sv.ImageViewer(im).show() 

这很好用,除了查看器作为前台进程运行,这意味着在关闭查看窗口之前我无法访问 ipython shell。我喜欢这个观众;至少对于灰度图像,光标显示当前像素的灰度级和索引。但我希望既能显示图像,又能继续在控制台中工作。我怎样才能最好地做到这一点?

请您参考如下方法:

解决了!只需要分两个阶段进行(根据文档);第一

from skimage.viewer import ImageViewer 

然后

fs = ImageViewer(f) 
fs.show() 

这工作正常(除了使用 ImageViewer 命令创建的空白图形窗口)。