Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
238 views
in Technique[技术] by (71.8m points)

python - Plot list of images with RGB values in numpy arrays

I have a list of numpy arrays that are RGB values of 3 images, as below:

array([[ 38,  45,  48],
   [ 38,  45,  48],
   [ 38,  45,  48],
   ...,
   [134, 125, 101],
   [134, 125, 101],
   [134, 125, 101]], dtype=uint8)

This has been generated with the code as shown below:

r, c, l = img_array.shape
img_disp = np.reshape(image, (r, c, l), order="C")
arr = img_disp.astype(dtype='uint8')
img = np.asarray(Image.fromarray(arr, 'RGB'))
img_to_display = np.vstack(img)

I'm trying to plot these images in a jupyter notebook.

Using plt.figure() and imshow() as suggested in other posts gives the following error.

for ima in images:
    plt.figure()
    plt.imshow(ima)

Error:

TypeError: Invalid shape (3,) for image data

May be a small thing, but I'm not able to get this around. The shape of my list is (255440, 3).

Appreciate any help!

question from:https://stackoverflow.com/questions/65903833/plot-list-of-images-with-rgb-values-in-numpy-arrays

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...