X-Git-Url: https://www.fleuret.org/cgi-bin/gitweb/gitweb.cgi?p=mlp.git;a=blobdiff_plain;f=images.cc;fp=images.cc;h=fac406bd921fd550702257a9ef3c57531ae5f88e;hp=e1b07b4dbe85ba5c0e20e61e641c921f69fd6f87;hb=a3e1c52fc152cbbbcc2c8c675f14efc0e653d6fd;hpb=713c683d77fc94a4257c4031b0c51ef4669a3d4a diff --git a/images.cc b/images.cc index e1b07b4..fac406b 100644 --- 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 + * Copyright (c) 2006 École Polytechnique Fédérale de Lausanne, + * http://www.epfl.ch + * + * Written by Francois Fleuret * * 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(); +}