91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

mnist手寫字符集(0-9),已經將idx3-ubyte格式數據提取為jpg圖片,方便學習研究深度學習和字符識別使用

資源截圖

代碼片段和文件信息

//下面的代碼將mnist官網上的數據轉化為圖片
//依賴C++11和opencv
#include
#include
#include
#include
#include

using?namespace?std;

inline?int?to_int?(const?void*data)
{
????unsigned?char*?ptr?=?(unsigned?char*)?data;
????int?result?=?0;
????
????for?(int?i?=?3;?i?>=?0;?i--)
????{
????????result?+=??ptr[i]?*?pow?(256?3?-?i);
????}
????
????return?result;
}

int?main()
{
????const?string?mnist_data_path?(R“(F:\libs\caffe\data\mnist\t10k-images-idx3-ubyte)“);
????const?string?mnist_label_path?(R“(F:\libs\caffe\data\mnist\t10k-labels-idx1-ubyte)“);
????const?string?dst_img_dir?(R“(F:\libs\caffe\data\mnist\test_10000)“);
????FILE?*?f_data_handle?=?fopen?(mnist_data_path.c_str()?“rb“);
????FILE?*?f_label_handle?=?fopen?(mnist_label_path.c_str()?“rb“);
????fseek?(f_label_handle?8?SEEK_SET);
????char?buff[4];
????fread?(?(void*)?&buff?4?1?f_data_handle);
????int?magic_num?=?to_int?(buff);
????fread?(?(void*)?&buff?4?1?f_data_handle);
????int?num_imgs?=?to_int?(buff);
????fread?(?(void*)?&buff?4?1?f_data_handle);
????int?num_rows?=?to_int?(buff);
????fread?(?(void*)?&buff?4?1?f_data_handle);
????int?num_cols?=?to_int?(buff);
????cv::Mat?img_buf?(num_rows?num_cols?CV_8U?cv::Scalar?(0));
????assert?(img_buf.isContinuous());
????unsigned?char*?pixel_ptr?=?img_buf.ptr?(0);
????int?count_all?=?-1;
????map?count_one;
????
????for?(int?i?=?0;?i?????{
????????if?(i?%?1000?==?0)?{?cout?<????????
????????unsigned?char?label?=?fgetc?(f_label_handle);
????????count_all++;
????????count_one[label]++;
????????
????????for?(int?j?=?0;?j?????????{
????????????pixel_ptr[j]?=?fgetc?(f_data_handle);
????????}
????????
????????cv::imwrite?(dst_img_dir?+?“\\“?+?(to_string?(label)?+?“_“?+?to_string?(count_one[label])?+?“_“?+?to_string?(count_all)?+?“.jpg“)?img_buf);
????????//cv::imshow?(“HH“?img_buf);
????????//cv::waitKey?(1);
????}
}

評論

共有 條評論