Conversion between Pillow Image object and numpy array changes dimension

后端 未结 3 1334
离开以前
离开以前 2020-12-25 13:03

I am using Pillow and numpy, but have a problem with conversion between Pillow Image object and numpy array.

when I execute following code, the result is weird.

3条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-25 13:43

    im maybe column-major while arrays in numpy are row-major

    do in_data = in_data.T to transpose the python array

    probably should check in_data with matplotlib's imshow to make sure the picture looks right.

    But do you know that matplotlib comes with its own loading functions that gives you numpy arrays directly? See: http://matplotlib.org/users/image_tutorial.html

提交回复
热议问题