I would like to read using python the following dataset: http://ufldl.stanford.edu/housenumbers/train_32x32.mat
I had loaded this mat file using io.loadmat('train_32x32.mat') but when I am trying to show an images from the above numpy array, I do not get the image with good resolution and coloring.
Any idea how to read and to plot images from this dataset?
The output of the loadmat function is a dictionary. See the code below:
import numpy as np
import scipy.io as sio
import matplotlib.pyplot as plt
%matplotlib inline
image_ind = 10
train_data = sio.loadmat('train_32x32.mat')
# access to the dict
x_train = train_data['X']
y_train = train_data['y']
# show sample
plt.imshow(x_train[:,:,:,image_ind])
plt.show()
print y_train[image_ind]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With