iRoCS Toolbox  1.1.0
BlitzImageReader.hh
Go to the documentation of this file.
1 /**************************************************************************
2  *
3  * Copyright (C) 2008 Alexandra Teynor
4  *
5  * Image Analysis Lab, University of Freiburg, Germany
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software Foundation,
19  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  *
21  **************************************************************************/
22 
23 /**********************************************************
24  *
25  * BlitzImageReader
26  * Class that loads data from various image formats to
27  * blitz arrays
28  *
29  * author: Alex Teynor (teynor@informatik.uni-freiburg.de)
30  * Dec. 2008
31  *
32  * extended by: Thorsten Schmidt (tschmidt@cs.uni-freiburg.de)
33  * Mar. 2013
34  *
35  *********************************************************/
36 
37 #ifndef _BLITZIMAGEREADER_HH
38 #define _BLITZIMAGEREADER_HH
39 
40 #ifdef HAVE_CONFIG_H
41 #include <config.hh>
42 #endif
43 
44 #include <cstddef>
45 #include <cstdio>
46 
47 #ifdef HAVE_LIBJPEG
48 namespace JPEGLIB {
49 // jpeg library
50  extern "C" {
51 #include <jpeglib.h>
52  }
53 }
54 #endif
55 
56 #ifdef HAVE_LIBTIFF
57 // TIFF lib
58 #include <tiffio.h>
59 #endif
60 
61 // PNG lib
62 #include <png.h>
63 
64 // Blitz arrays
65 #include <blitz/array.h>
66 
67 #include "ImageAccessWrapper.hh"
68 
71 
72 public:
73 
74 #ifdef HAVE_LIBJPEG
75 
76  /*======================================================================*/
92  /*======================================================================*/
93  static int readJPEG(blitz::Array<unsigned char,3> &data,
94  const std::string& fileName);
95 
96 
97  /*======================================================================*/
112  /*======================================================================*/
113  static int readJPEG(blitz::Array<blitz::TinyVector<unsigned char,3>,2> &data,
114  const std::string& fileName);
115 
116 
117  /*======================================================================*/
129  /*======================================================================*/
130  static int readJPEG(ImageAccessWrapper &data,
131  const std::string& fileName);
132 
133 #endif
134 
135  /*======================================================================*/
151  /*======================================================================*/
152  static int readPNG(blitz::Array<unsigned char,3> &data,
153  const std::string& fileName);
154 
155 
156  /*======================================================================*/
171  /*======================================================================*/
172  static int readPNG(blitz::Array<blitz::TinyVector<unsigned char,3>, 2> &data,
173  const std::string& fileName);
174 
175 
176  /*======================================================================*/
188  /*======================================================================*/
189  static int readPNG(ImageAccessWrapper &data,
190  const std::string& fileName);
191 
192  /*======================================================================*/
211  /*======================================================================*/
212  static int readPNM(blitz::Array<unsigned char,3> &data,
213  const std::string& fileName);
214 
215 
216  /*======================================================================*/
233  /*======================================================================*/
234  static int readPNM(blitz::Array<blitz::TinyVector<unsigned char,3>, 2> &data,
235  const std::string& fileName);
236 
237 
238  /*======================================================================*/
251  /*======================================================================*/
252  static int readPNM(ImageAccessWrapper &data,
253  const std::string& fileName);
254 
255 #ifdef HAVE_LIBTIFF
256 
257  /*======================================================================*/
273  /*======================================================================*/
274  static int readTIFF(blitz::Array<unsigned char,3> &data,
275  const std::string& fileName);
276 
277 
278  /*======================================================================*/
293  /*======================================================================*/
294  static int readTIFF(blitz::Array<blitz::TinyVector<unsigned char,3>, 2> &data,
295  const std::string& fileName);
296 
297 
298  /*======================================================================*/
310  /*======================================================================*/
311  static int readTIFF(ImageAccessWrapper &data,
312  const std::string& fileName);
313 
314 #endif
315 
316 private:
317 
318  static std::istream &pnmSkipToNextToken(std::istream &pnmStream);
319 
320 };
321 
322 #endif
323 
To allow for different blitz storage formats to be handeled equally.
Class that loads data from various image formats to blitz arrays.