0
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.

JohanC
  • 71,591
  • 8
  • 33
  • 66

2 Answers2

3

You can use the skimage.io.imsave function to save. It looks like the images will already plot, so can I suggest editing your function to return the region of interest in the image:

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. Other image files can also be saved using the imsave function.

Paddy Harrison
  • 1,808
  • 1
  • 8
  • 21
  • I tried it but it is giving warning as Lossy conversion from float64 to uint8. Range [0, 1]. Convert image to uint8 prior to saving to suppress this warning. – mitali angane Apr 27 '20 at 10:07
  • 1
    I think the image would save despite the warning, it's just suggesting that the image quality may be worse when converting to 8bit required for png. You can use the function `skimage.util.img_as_ubyte` to convert the image before saving and remove the warning but I think this is not necessary. – Paddy Harrison Apr 27 '20 at 10:55
0

you can also use concurrent.futures

with concurrent.futures.ProcessPoolExecutor() as executor:
                    executor.map(io.imsave, destination_corrections, images)