import os
import mahotas
from PIL import Image
from pylab import *
path='all_images'
for file in os.listdir(path):
current = os.path.join(path, file)
extension = os.path.splitext(current)[-1]
fileType = extension.upper()
if os.path.isfile(current):
im = array(Image.open(current).convert('L'))
# create a new figure
figure()
# show contours with origin upper left corner
contour(im, origin='image')
axis('equal')
show() # This is showing contour image, I want to save this in the next line
mahotas.imsave(current+'.png',im)show()命令显示转换后的图像的图形。但在此之后,该图形不能保存在下一行中。我想保存show命令中的图形。在这方面,有人能帮上忙吗?
发布于 2013-11-30 20:42:09
本质上,这不是关于mahotas的。mahotas.imsave将保存它的参数,而您传递给它的是im,这是不变的。
要保存使用pylab生成的等值线,应查看matplotlib.pyplot.savefig
savefig('contours.png')https://stackoverflow.com/questions/20283589
复制相似问题