Home > other >  Serial output of Python images
Serial output of Python images

Time:09-21

How can I render images sequentially in Spyder? At the moment, it turns out to display only the last image

from skimage.io import imread, imshow

img_5 = imread('C:/abc1.png')
imshow(img_5)

img_6 = imread('C:/abc2.png')
imshow(img_6)

CodePudding user response:

I did not try it in spyder, but you can check:

imshow(img_5, block=False)

Do not use block=False in the last plot, otherwise the plots are closed when the script is finished.

CodePudding user response:

you can do this with from IPython.display import display like below:

from IPython.display import display, Image

for img in ['C:/abc1.png', 'C:/abc2.png']:
    ima = Image(filename=img , width=300,height=200)
    display(ima)

If you want to use imshow you can use plt.imshow like below:

import matplotlib.pyplot as plt
from skimage.io import imread, imshow


img_5 = imread('C:/abc1.png')
plt.imshow(img_5)
plt.show()

img_6 = imread('C:/abc2.png')
plt.imshow(img_6)
plt.show()

You can do this with opencv-python like below (if you didn't have installed opencv try this code : pip install opencv-python)

import cv2
for img in ['C:/abc1.png', 'C:/abc2.png']:
    im = cv2.imread(img)
    im = cv2.cvtColor(im, cv2.COLOR_BGR2RGB)
    plt.imshow(im)
    plt.show()
  • Related