我正在尝试通过提供一个with语句和一个文本文件来处理目录中的多个图像,该文本文件列出了我要处理的文件的文件路径(处理过程包括所示的灰阶显示以及一些降噪和像素强度测量)。 使用下面显示的代码,程序可以正确处理列表中的第一个文件,但在处理其他文件之前结束。有谁知道为什么以及如何让我遍历列出的所有文件?
#establish loop
with open('file_list.txt') as inf:
for line in inf:
path = line
# grayscale and plot
original = io.imread(path,plugin = 'pil')
grayscale = rgb2gray(original)