X-Git-Url: https://www.fleuret.org/cgi-bin/gitweb/gitweb.cgi?p=mlp.git;a=blobdiff_plain;f=images.h;fp=images.h;h=71e0440216b45dead5ccbc8a5c09b5bfd4b798d0;hp=0000000000000000000000000000000000000000;hb=713c683d77fc94a4257c4031b0c51ef4669a3d4a;hpb=751279426fb49172dfe95d85dd277e06a970577e diff --git a/images.h b/images.h new file mode 100644 index 0000000..71e0440 --- /dev/null +++ b/images.h @@ -0,0 +1,75 @@ +/* + * 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 + * + * This file is part of mlp-mnist. + * + * mlp-mnist is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3 as + * published by the Free Software Foundation. + * + * mlp-mnist is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with mlp-mnist. If not, see . + * + */ + +// $Id: images.h,v 1.1 2005-12-13 17:19:11 fleuret Exp $ + +#ifndef IMAGES_H +#define IMAGES_H + +#include +#include +#include + +using namespace std; + +#include "features.h" + +class PixelMaps { +public: + unsigned int _nb_ref; + unsigned char *_core; + PixelMaps(int size); + ~PixelMaps(); + PixelMaps *add_ref(); + void del_ref(); +}; + +class ImageSet { + int _nb_pics, _nb_obj; + int _width, _height; + PixelMaps *_pixel_maps; + unsigned char **_pixels, *_labels; + bool *_used_picture; + +public: + ImageSet(); + ~ImageSet(); + + inline int nb_pics() { return _nb_pics; } + inline int nb_obj() { return _nb_obj; } + inline int width() { return _width; } + inline int height() { return _height; } + inline unsigned char *pixels(int p) { return _pixels[p]; } + inline unsigned char pixel(int p, int x, int y) { return _pixels[p][x + y * _width]; } + inline unsigned char label(int p) { return _labels[p]; } + + void reset_used_pictures(); + int nb_unused_pictures(); + int pick_unused_picture(); + + void load_mnist_format(char *picture_file_name, char *label_file_name); + + void extract_unused_pictures(ImageSet &is, int nb); + +}; + +#endif