27 b0 = (n & 0x000000ff) << 24u;
28 b1 = (n & 0x0000ff00) << 8u;
29 b2 = (n & 0x00ff0000) >> 8u;
30 b3 = (n & 0xff000000) >> 24u;
32 return (b0 | b1 | b2 | b3);
57 fread(&ifh->
imgWidth, 4, 1, imageFile);
97 imageFile = fopen (fileName,
"rb");
98 if (imageFile == NULL) {
99 printf(
"Abort! Could not fine MNIST IMAGE file: %s\n",fileName);
121 labelFile = fopen (fileName,
"rb");
122 if (labelFile == NULL) {
123 printf(
"Abort! Could not find MNIST LABEL file: %s\n",fileName);
144 result = fread(&img,
sizeof(img), 1, imageFile);
146 printf(
"\nError when reading IMAGE file! Abort!\n");
164 result = fread(&lbl,
sizeof(lbl), 1, labelFile);
166 printf(
"\nError when reading LABEL file! Abort!\n");
FILE * openMNISTImageFile(char *fileName)
Read MNIST IMAGE file header.
FILE * openMNISTLabelFile(char *fileName)
Read MNIST label file header.
MNIST_Label getLabel(FILE *labelFile)
Returns the next label in given MNIST label file.
uint32_t flipBytes(uint32_t n)
void readImageFileHeader(FILE *imageFile, MNIST_ImageFileHeader *ifh)
Utitlies for handling the MNIST files.
MNIST_Image getImage(FILE *imageFile)
Returns the next image in given MNIST image file.
Data block defining a MNIST image.
void readLabelFileHeader(FILE *imageFile, MNIST_LabelFileHeader *lfh)