简体   繁体   English

如何使用 skimage 和 numpy 显示和保存 output 图像?

[英]How to show and save output images using skimage and numpy?

def show_image_in_region(region):
    minr, minc, maxr, maxc = region.bbox
    plt.imshow(binary_imag[minr:maxr,minc:maxc])

for i in range(0,5):
    show_image_in_region(image_blocks[i])

I have multiple output images which I want to save and display using skimage.我有多个 output 图像,我想使用 skimage 保存和显示它们。

You can use the skimage.io.imsave function to save.您可以使用skimage.io.imsave function 来保存。 It looks like the images will already plot, so can I suggest editing your function to return the region of interest in the image:看起来图像已经 plot,所以我可以建议编辑您的 function 以返回图像中的感兴趣区域:

from skimage.io import imsave

def show_image_in_region(region):
    minr, minc, maxr, maxc = region.bbox
    plt.imshow(binary_imag[minr:maxr,minc:maxc])
    return binary_imag[minr:maxr,minc:maxc]

and then in your loop:然后在你的循环中:

for i in range(0,5):
    im = show_image_in_region(image_blocks[i])
    imsave('image{}.png'.format(i), im)

which will save a.png file called "image0.png" and so on.这将保存一个名为“image0.png”的.png文件等等。 Other image files can also be saved using the imsave function.也可以使用imsave function 保存其他图像文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM