libidx
|
00001 /*************************************************************************** 00002 * Copyright (C) 2008 by Yann LeCun and Pierre Sermanet * 00003 * yann@cs.nyu.edu, pierre.sermanet@gmail.com * 00004 * All rights reserved. 00005 * 00006 * Redistribution and use in source and binary forms, with or without 00007 * modification, are permitted provided that the following conditions are met: 00008 * * Redistributions of source code must retain the above copyright 00009 * notice, this list of conditions and the following disclaimer. 00010 * * Redistributions in binary form must reproduce the above copyright 00011 * notice, this list of conditions and the following disclaimer in the 00012 * documentation and/or other materials provided with the distribution. 00013 * * Redistribution under a license not approved by the Open Source 00014 * Initiative (http://www.opensource.org) must display the 00015 * following acknowledgement in all advertising material: 00016 * This product includes software developed at the Courant 00017 * Institute of Mathematical Sciences (http://cims.nyu.edu). 00018 * * The names of the authors may not be used to endorse or promote products 00019 * derived from this software without specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 00022 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00023 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00024 * DISCLAIMED. IN NO EVENT SHALL ThE AUTHORS BE LIABLE FOR ANY 00025 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00026 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00027 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00028 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00029 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00030 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00031 ***************************************************************************/ 00032 00033 #ifndef IMAGEIO_H_ 00034 #define IMAGEIO_H_ 00035 00036 #include "libidx.h" 00037 00038 namespace ebl { 00039 00041 // loading 00042 00049 template <class T> 00050 void load_image(const char *fname, idx<T> &out); 00051 00058 template <class T> 00059 void load_image(const string &fname, idx<T> &out); 00060 00067 template <class T> 00068 idx<T> load_image(const char *fname); 00069 00076 template <class T> 00077 idx<T> load_image(const string &fname); 00078 00080 // saving 00081 00082 // format is the desired image format. e.g.: "JPG", "PNG", etc. 00083 template <class T> bool save_image(const string &fname, idx<T> &in, 00084 const char *format); 00085 template <class T> bool save_image_ppm(const string &fname, idx<T> &in); 00086 template <class T> bool save_image_ppm(const char *fname, idx<T> &in); 00087 template <class T> bool save_image_ppm(FILE *fp, idx<T> &in); 00088 template <class T> bool save_image_jpg(const string &fname, idx<T> &in); 00089 00091 // helper functions 00092 00101 EXPORT idx<ubyte> pnm_read(FILE *fp, idx<ubyte> *out = NULL); 00102 00103 // EXPORT idx<ubyte> pnm_read2(istream &in, idx<ubyte> *out = NULL); 00104 00110 template <class T> 00111 idx<T> image_read(const char *fname, idx<T> *out = NULL, int attempts = 3); 00112 00113 } // end namespace ebl 00114 00115 #include "imageIO.hpp" 00116 00117 #endif /* IMAGEIO_H_ */