automatic commit
[mlp.git] / images.cc
index e1b07b4..fac406b 100644 (file)
--- a/images.cc
+++ b/images.cc
@@ -1,8 +1,10 @@
 /*
  *  mlp-mnist is an implementation of a multi-layer neural network.
  *
- *  Copyright (c) 2008 Idiap Research Institute, http://www.idiap.ch/
- *  Written by Francois Fleuret <francois.fleuret@idiap.ch>
+ *  Copyright (c) 2006 École Polytechnique Fédérale de Lausanne,
+ *  http://www.epfl.ch
+ *
+ *  Written by Francois Fleuret <francois@fleuret.org>
  *
  *  This file is part of mlp-mnist.
  *
@@ -68,29 +70,6 @@ int ImageSet::pick_unused_picture() {
   return m;
 }
 
-void ImageSet::extract_unused_pictures(ImageSet &is, int nb) {
-  if(nb > is.nb_unused_pictures()) {
-    cerr << "Trying to extract " << nb << " pictures from a set of " << is.nb_unused_pictures() << "\n";
-    exit(1);
-  }
-
-  _nb_pics = nb;
-  _width = is._width;
-  _height = is._height;
-  _nb_obj = is._nb_obj;
-  _pixel_maps = is._pixel_maps->add_ref();
-  _pixels = new unsigned char *[_nb_pics];
-  _labels = new unsigned char[_nb_pics];
-  _used_picture = new bool[_nb_pics];
-  for(int n = 0; n < _nb_pics; n++) {
-    int m = is.pick_unused_picture();
-    _pixels[n] = is._pixels[m];
-    _labels[n] = is._labels[m];
-  }
-
-  reset_used_pictures();
-}
-
 void ImageSet::load_mnist_format(char *picture_file_name, char *label_file_name) {
   unsigned int magic;
 
@@ -151,3 +130,26 @@ void ImageSet::load_mnist_format(char *picture_file_name, char *label_file_name)
 
   reset_used_pictures();
 }
+
+void ImageSet::sample_among_unused_pictures(ImageSet &is, int nb) {
+  if(nb > is.nb_unused_pictures()) {
+    cerr << "Trying to extract " << nb << " pictures from a set of " << is.nb_unused_pictures() << "\n";
+    exit(1);
+  }
+
+  _nb_pics = nb;
+  _width = is._width;
+  _height = is._height;
+  _nb_obj = is._nb_obj;
+  _pixel_maps = is._pixel_maps->add_ref();
+  _pixels = new unsigned char *[_nb_pics];
+  _labels = new unsigned char[_nb_pics];
+  _used_picture = new bool[_nb_pics];
+  for(int n = 0; n < _nb_pics; n++) {
+    int m = is.pick_unused_picture();
+    _pixels[n] = is._pixels[m];
+    _labels[n] = is._labels[m];
+  }
+
+  reset_used_pictures();
+}