ConvNet  1.0
A GPU-based C++ implementation of Convolutional Neural Nets
 All Classes Namespaces Functions Variables
image_iterators.h
1 #ifndef IMAGE_ITERATORS_
2 #define IMAGE_ITERATORS_
3 #define cimg_use_jpeg
4 #define cimg_use_lapack
5 #include <string>
6 #include <iostream>
7 #include <vector>
8 #include "CImg.h"
9 using namespace cimg_library;
10 using namespace std;
11 
16 template<typename T>
18  public:
19  RawImageFileIterator(const string& filelist, const int image_size,
20  const int raw_image_size, const bool flip,
21  const bool translate);
22 
23  // Memory must already be allocated : num_dims * num_dims * 3.
24  void GetNext(T* data_ptr);
25  void GetNext(T* data_ptr, const int row, const int position);
26 
27  void Seek(int row) { row_ = row; }
28  int GetDataSetSize() const { return dataset_size_;}
29 
30  private:
31  void GetCoordinates(int width, int height, int position, int* left, int* top, bool* flip);
32 
33  int dataset_size_, row_, image_id_, position_;
34  vector<string> filenames_;
35  CImg<T> image_;
36  const int image_size_, num_positions_, raw_image_size_;
37  CImgDisplay* disp_;
38 };
39 
41 template<typename T>
43  public:
44  SlidingWindowIterator(const int window_size, const int stride);
45  void SetImage(const string& filename);
46  int GetNumWindows() { return num_windows_;}
47  void GetNext(T* data_ptr);
48  void GetNext(T* data_ptr, int left, int top);
49  bool Done();
50  void Reset();
51 
52  private:
53  const int window_size_, stride_;
54  int num_windows_, center_x_, center_y_;
55  CImg<T> image_;
56  bool done_;
57 };
58 
59 
60 #endif
An iterator over list of image files.
Definition: image_iterators.h:17
STL namespace.
An iterator over sliding windows of an image.
Definition: image_iterators.h:42