TarzaNN
TarzaNN neural network simulator
C:/Users/albertlr/projects/TarzaNN/TarzaNN/NorbDataset.h
Go to the documentation of this file.
00001 /****************************************************************************
00002  **
00003  ** Copyright C 2002-2012 Laboratory for Active and Attentive Vision (LAAV), Department of Computer Science and Engineering, York University, Toronto, ON, Canada.
00004  ** All rights reserved.
00005  **
00006  ** This file is part of the TarzaNN Neural Network Simulator.
00007  **
00008  ** This file may be distributed and/or modified under the terms of the
00009  ** GNU General Public License version 2 as published by the Free Software
00010  ** Foundation and appearing in the file LICENSE.GPL included in the
00011  ** packaging of this file.
00012  **
00013  ** See http://www.tarzann.org/gpl/ for GPL licensing information.
00014  **
00015  ** Contact info@tarzann.org if any conditions of this licensing are
00016  ** not clear to you.
00017  **
00018  ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00019  ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00020  **
00021  ****************************************************************************/
00022 
00023 #ifndef NORBDATASET_H_INCLUDED
00024 #define NORBDATASET_H_INCLUDED
00025 
00026 #include <vector>
00027 using namespace std;
00028 #include "OutputImage.h"
00029 #include "Dataset.h"
00030 
00031 #define MODULO 5
00032 
00033 #define SWAP_LONG( A )  ((A << 24) | ((A & 0xff00L) << 8 ) | ((A & 0xff0000L) >> 8 ) | ((unsigned long)A >> 24))
00034 
00035 struct imageHeader {
00036         int magic; // 4 bytes
00037         int ndim; // 4 bytes, little endian
00038         int dim[4];
00039 };
00040 
00041 struct infoHeader {
00042         int magic; // 4 bytes
00043         int ndim; // 4 bytes, little endian
00044         int dim[3];
00045 };
00046 
00047 struct categoryHeader {
00048         int magic; // 4 bytes
00049         int ndim; // 4 bytes, little endian
00050         int dim[3];
00051 };
00052 
00053 
00055 class NORB_Dataset : public Dataset{
00056 protected:
00057         long imageBaseOffset;
00058         long imageSize;
00059         FILE* imageFile;
00060         OutputImage* imageL;
00061         OutputImage* imageR;
00062 
00063         long categoryBaseOffset;
00064         long categorySize;
00065         FILE* categoryFile;
00066         
00067         long infoBaseOffset;
00068         long infoSize;
00069         FILE* infoFile;
00070         int info[10];
00071 
00072         void init(char* basefilename);
00073         void readImageFile(char* filename);
00074         void readCategoryFile(char* filename);
00075         void readInfoFile(char* filename);
00076         int IMAGE_SIZE, INPUT_IMAGE_SIZE;
00077 
00078 public:
00080         NORB_Dataset(char* basefilename);
00081         ~NORB_Dataset();
00083         OutputImage* getImage(int index, OutputImage** list, int LorR);
00085         Matrix* getDesiredOutcome(int index);
00087         int* getInfo(int index);
00088 };
00089 #endif/*NORBDATASET_H_INCLUDED*/
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines