0
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 命令中保存图形。任何人都可以在这方面提供帮助吗?

4

1 回答 1

1

这与 mahotas 本身无关。mahotas.imsave将保存它的参数并且你正在传递它im,它是不变的。

要保存您生成的轮廓pylab,您应该查看matplotlib.pyplot.savefig

savefig('contours.png')
于 2013-11-30T12:42:09.407 回答