Why CIFAR-10 images are not displayed properly using matplotlib?

前端 未结 9 852
独厮守ぢ
独厮守ぢ 2021-02-06 12:28

From the training set I took a image(\'img\') of size (3,32,32). I have used plt.imshow(img.T). The image is not clear. Now changes I have to make to image(\'img\') to make it m

9条回答
  •  不知归路
    2021-02-06 13:15

    The image is blurry due to interpolation. To prevent blurring in matplotlib, call imshow with keyword interpolation='nearest':

    plt.imshow(img.T, interpolation='nearest')
    

    Also, it appears that your x and y axes are being swapped when you use the transpose so you may want to display like this instead:

    plt.imshow(np.transpose(img, (1, 2, 0)), interpolation='nearest')
    

提交回复
热议问题