-1

I've been using datasets from sklearn. And I want to show image from 'MNIST original' using openCV.imshow

Here is part of my code

dataset = datasets.fetch_mldata('MNIST original')
features = np.array(dataset.data, 'int16')
labels = np.array(dataset.target, 'int')



list_hog_fd = []
deskewed_images = []
for img in features:
     cv2.imshow("digit", img)
     deskewed_images.append(deskew(img))

"digit" window appears but it is definitely not an digit image. How can I access real image from dataset?

Milorad
  • 155
  • 14

1 Answers1

0

Shape

MNIST image datasets generally are distributed and used as a 1D vector of 784 values.

However, in order to show it as image, you need to convert it to a 2D matrix with 28*28 values.

Simply using img = img.reshape(28,28) might work in your case.

Peteris
  • 3,281
  • 2
  • 25
  • 40
  • Thanks for answer but strange thing happens now. Namely it is still not shown with cv,imshow as it should , but when I click "view as array" in PyCharm i can see different colored pixel as cells in 2D array which form numbers. – Milorad Jan 28 '18 at 20:30