5

How do I do the above ? This is my code but it doesn't work nothing is displayed

from PIL import Image
import glob
image_list = []
for filename in glob.glob('<my directory>.pgm'):
    im=Image.open(filename)
    image_list.append(im)

import matplotlib.pyplot as plt

for i in range(10):
    plt.figure()
    plt.imshow(image_list[i])

I would like it to be displayed in the cell

Kong
  • 2,202
  • 8
  • 28
  • 56

2 Answers2

7

If you're interested in a much simpler and faster way of displaying images I recommend IPyPlot package:

import ipyplot

ipyplot.plot_images(images_list, max_images=20, img_width=150)

It's capable of displaying hundreds of images in a grid-like format within just 60-70ms

You would get a plot similar to this:
enter image description here

Karol Żak
  • 2,158
  • 20
  • 24
2

In your case, you should add %matplotlib inlinebefore your code and make sure that after plt.imshow(images_list) you add plt.show() as well so matplotlib renders your images.

mkarts
  • 667
  • 5
  • 10