mnist itself is a digital handwritten image, information synthesis after normalization documents, sub-training set and test set two sections, each section contains pictures and tag two documents, as used herein, written in C ++ Demo document decoding, and by opencv will the image data is stored as regular documents. Source Download: https://github.com/zacSuo/mnist
t10k-images.idx3-ubyte
t10k-labels.idx1-ubyte
train-images.idx3-ubyte
train-labels.idx1-ubyte
Instructions for use
Environmental requirements
visual studio 2012 or later
opencv 2.4 and above
Configuration
Before starting the first through the project properties, set the path of the local opencv.
Results of the
In the two documents directory folder, respectively to save the test set (test_images) and the training set (train_images) pictures into it.
int(std::string filename, std::vector<cv::Mat> &vec) { int number_of_images = 0; std::ifstream file(filename, std::ios::binary); if (file.is_open()) { int magic_number = 0; int n_rows = 0; int n_cols = 0; file.read((char*)&magic_number, sizeof(magic_number)); magic_number = ReverseInt(magic_number); file.read((char*)&number_of_images, sizeof(number_of_images)); number_of_images = ReverseInt(number_of_images); file.read((char*)&n_rows, sizeof(n_rows)); n_rows = ReverseInt(n_rows); file.read((char*)&n_cols, sizeof(n_cols)); n_cols = ReverseInt(n_cols);
for (int i = 0; i < number_of_images; ++i) { cv::Mat tp = cv::Mat::zeros(n_rows, n_cols, CV_8UC1); for (int r = 0; r < n_rows; ++r) { for (int c = 0; c < n_cols; ++c) { unsignedchar temp = 0; file.read((char*)&temp, sizeof(temp)); tp.at<uchar>(r, c) = (int)temp; } } vec.push_back(tp); }