Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/364.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 是否将子地块保存为图像?怎么做_Python_Matplotlib - Fatal编程技术网

Python 是否将子地块保存为图像?怎么做

Python 是否将子地块保存为图像?怎么做,python,matplotlib,Python,Matplotlib,运行此操作后,我不希望它显示,但将图像放入文件夹只需使用plt.savefig()而不是plt.show(): 这回答了你的问题吗? def sample_stack(stack, rows=8, cols=8, start_with=1, show_every=1): fig,ax = plt.subplots(rows,cols,figsize=[12,12]) for i in range(rows*cols): ind = start_with + i*s

运行此操作后,我不希望它显示,但将图像放入文件夹

只需使用plt.savefig()而不是plt.show():


这回答了你的问题吗?
def sample_stack(stack, rows=8, cols=8, start_with=1, show_every=1):
    fig,ax = plt.subplots(rows,cols,figsize=[12,12])
    for i in range(rows*cols):
        ind = start_with + i*show_every
        ax[int(i/rows),int(i % rows)].set_title('slice %d' % ind)
        ax[int(i/rows),int(i % rows)].imshow(stack[ind],cmap='gray')
        ax[int(i/rows),int(i % rows)].axis('off')
images = sample_stack(imgs_to_process)
plt.savefig(filepath)