Using this code :
from scipy import misc
import matplotlib.pyplot as plt
images = data.test.images[0:9]
plt.imshow(images[0].reshape(28 , 28))
print(images[0].shape)
I plot the image :
Using misc
from scipy
:
face = misc.face()
misc.imsave('face.png', face) # First we need to create the PNG file
face = misc.imread('face.png')
print(face.shape)
plt.imshow(face)
I plot image :
How to convert face
to 2 dimensional image which can be plotted using plt.imshow
?
Using :
plt.imshow(face.reshape(768 , 1024))
produces error :
ValueError Traceback (most recent call last)
<ipython-input-104-99fef1cec0d2> in <module>()
6 plt.imshow(face)
7
----> 8 plt.imshow(face.reshape(768 , 1024))
ValueError: cannot reshape array of size 2359296 into shape (768,1024)
I'm not attempting to convert the image to greyscale but to 2 dimensional instead of 3 dimensional.
Update :
Checking the a single pixel value : print(face[0][0])
is : [121 112 131]
. Should I take the average of [121 112 131]
as part of reshaping ?