[ VIGRA Homepage | Class Index | Function Index | File Index | Main Page ]
![]() |
vigra/imageinfo.hxx | ![]() |
---|
00001 /************************************************************************/ 00002 /* */ 00003 /* Copyright 1998-2001 by Ullrich Koethe */ 00004 /* Copyright 2001-2002 by Gunnar Kedenburg */ 00005 /* Cognitive Systems Group, University of Hamburg, Germany */ 00006 /* */ 00007 /* This file is part of the VIGRA computer vision library. */ 00008 /* ( Version 1.2.0, Aug 07 2003 ) */ 00009 /* You may use, modify, and distribute this software according */ 00010 /* to the terms stated in the LICENSE file included in */ 00011 /* the VIGRA distribution. */ 00012 /* */ 00013 /* The VIGRA Website is */ 00014 /* http://kogs-www.informatik.uni-hamburg.de/~koethe/vigra/ */ 00015 /* Please direct questions, bug reports, and contributions to */ 00016 /* koethe@informatik.uni-hamburg.de */ 00017 /* */ 00018 /* THIS SOFTWARE IS PROVIDED AS IS AND WITHOUT ANY EXPRESS OR */ 00019 /* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */ 00020 /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ 00021 /* */ 00022 /************************************************************************/ 00023 00024 #ifndef VIGRA_IMAGEINFO_HXX 00025 #define VIGRA_IMAGEINFO_HXX 00026 00027 #include <memory> 00028 #include <string> 00029 #include "vigra/utilities.hxx" 00030 #include "vigra/codec.hxx" 00031 00032 namespace vigra 00033 { 00034 /** \addtogroup VigraImpex Image Import/Export Facilities 00035 00036 supports GIF, TIFF, JPEG, BMP, PNM (PBM, PGM, PPM), PNG, SunRaster, KHOROS-VIFF formats 00037 **/ 00038 //@{ 00039 00040 /** \brief List the image formats VIGRA can read and write. 00041 00042 This is useful for creating error messages if VIGRA encounters an 00043 image format it doesn't recognize. 00044 00045 <b> Usage:</b> 00046 00047 <b>\#include</b> "<a href="imageinfo_8hxx-source.html">vigra/imageinfo.hxx</a>"<br> 00048 Namespace: vigra 00049 00050 \code 00051 std::cout << "supported formats: " << vigra::impexListFormats() << std::endl; 00052 \endcode 00053 00054 **/ 00055 std::string impexListFormats(); 00056 00057 /** \brief List the file extension VIGRA understands. 00058 00059 This is useful for creating file dialogs that only list image files 00060 VIGRA can actually import. 00061 00062 <b> Usage:</b> 00063 00064 <b>\#include</b> "<a href="imageinfo_8hxx-source.html">vigra/imageinfo.hxx</a>"<br> 00065 Namespace: vigra 00066 00067 \code 00068 std::cout << "supported extensions: " << vigra::impexListExtensions() << std::endl; 00069 \endcode 00070 00071 **/ 00072 std::string impexListExtensions(); 00073 00074 /** \brief Test whether a file is an image format known to VIGRA. 00075 00076 This checks the first few bytes of the file and compares them with the 00077 "magic strings" of each recognized image format. 00078 00079 <b> Usage:</b> 00080 00081 <b>\#include</b> "<a href="imageinfo_8hxx-source.html">vigra/imageinfo.hxx</a>"<br> 00082 Namespace: vigra 00083 00084 \code 00085 std::cout << "is image: " << vigra::isImage("foo.bmp") << std::endl; 00086 \endcode 00087 00088 **/ 00089 bool isImage(char const * filename); 00090 00091 /********************************************************/ 00092 /* */ 00093 /* ImageExportInfo */ 00094 /* */ 00095 /********************************************************/ 00096 00097 /** \brief Argument object for the function exportImage(). 00098 See \ref exportImage() for usage example. This object must be used 00099 to define the properties of an image to be written to disk. 00100 00101 <b>\#include</b> "<a href="imageinfo_8hxx-source.html">vigra/imageinfo.hxx</a>"<br> 00102 Namespace: vigra 00103 **/ 00104 class ImageExportInfo 00105 { 00106 public: 00107 /** Construct ImageExportInfo object. 00108 00109 The image will be stored under the given filename. 00110 The file type will be guessed from the extension unless overridden 00111 by \ref setFileType(). Recognized extensions: '.bmp', '.gif', 00112 '.jpeg', '.jpg', '.p7', '.png', '.pbm', '.pgm', '.pnm', '.ppm', '.ras', 00113 '.tif', '.tiff', '.xv'. 00114 JPEG support requires libjpeg, PNG support requires libpng, and 00115 TIFF support requires libtiff. 00116 **/ 00117 ImageExportInfo( const char * ); 00118 00119 const char * getFileName() const; 00120 00121 /** Store image as given file type. 00122 00123 This will override any type guessed 00124 from the file name's extension. Recognized file types: 00125 00126 <DL> 00127 <DT>"BMP"<DD> Microsoft Windows bitmap image file. 00128 <DT>"GIF"<DD> CompuServe graphics interchange format; 8-bit color. 00129 <DT>"JPEG"<DD> Joint Photographic Experts Group JFIF format; 00130 compressed 24-bit color (only available if libjpeg is installed). 00131 <DT>"PNG"<DD> Portable Network Graphic 00132 (only available if libpng is installed). 00133 <DT>"PBM"<DD> Portable bitmap format (black and white). 00134 <DT>"PGM"<DD> Portable graymap format (gray scale). 00135 <DT>"PNM"<DD> Portable anymap. 00136 <DT>"PPM"<DD> Portable pixmap format (color). 00137 <DT>"SUN"<DD> SUN Rasterfile. 00138 <DT>"TIFF"<DD> Tagged Image File Format. 00139 (only available if libtiff is installed.) 00140 <DT>"VIFF"<DD> Khoros Visualization image file. 00141 </DL> 00142 00143 With the exception of TIFF and VIFF, all file types store 00144 1 byte (gray scale and mapped RGB) or 3 bytes (RGB) per 00145 pixel. 00146 00147 TIFF and VIFF are aditionally able to store short and long 00148 integers (2 or 4 bytes) and real values (32 bit float and 00149 64 bit double) without conversion. So you will need to use 00150 TIFF or VIFF if you need to store images with high 00151 accuracy (the appropriate type to write is automatically 00152 derived from the image type to be exported). However, many 00153 other programs using TIFF (e.g. ImageMagick) have not 00154 implemented support for those pixel types. So don't be 00155 surprised if the generated TIFF is not readable in some 00156 cases. If this happens, convert the image to 'unsigned 00157 char' or 'RGBValue<unsigned char>' prior to exporting. 00158 **/ 00159 ImageExportInfo & setFileType( const char * ); 00160 const char * getFileType() const; 00161 00162 /** Set compression type. 00163 00164 Recognized strings: "LZW", 00165 "RunLength", "1" ... "100". A number is interpreted as the 00166 compression quality for JPEG compression. JPEG compression is 00167 supported by the JPEG and TIFF formats. 00168 **/ 00169 ImageExportInfo & setCompression( const char * ); 00170 const char * getCompression() const; 00171 00172 /** Set the pixel type of the image. Possible values are: 00173 <DL> 00174 <DT>"UINT8"<DD> 8-bit unsigned integer (unsigned char) 00175 <DT>"INT16"<DD> 16-bit signed integer (short) 00176 <DT>"INT32"<DD> 32-bit signed integer (long) 00177 <DT>"FLOAT"<DD> 32-bit floating point (float) 00178 <DT>"DOUBLE"<DD> 64-bit floating point (double) 00179 </DL> 00180 **/ 00181 ImageExportInfo & setPixelType( const char * ); 00182 00183 /** Get the pixel type of the image. Possible values are: 00184 <DL> 00185 <DT>"UINT8"<DD> 8-bit unsigned integer (unsigned char) 00186 <DT>"INT16"<DD> 16-bit signed integer (short) 00187 <DT>"INT32"<DD> 32-bit signed integer (long) 00188 <DT>"FLOAT"<DD> 32-bit floating point (float) 00189 <DT>"DOUBLE"<DD> 64-bit floating point (double) 00190 </DL> 00191 **/ 00192 const char * getPixelType() const; 00193 00194 /** Set the image resolution in horizontal direction 00195 **/ 00196 ImageExportInfo & setXResolution( float ); 00197 00198 /** Set the image resolution in vertical direction 00199 **/ 00200 ImageExportInfo & setYResolution( float ); 00201 00202 float getXResolution() const; 00203 float getYResolution() const; 00204 00205 private: 00206 std::string m_filename, m_filetype, m_pixeltype, m_comp; 00207 float m_x_res, m_y_res; 00208 }; 00209 00210 // return an encoder for a given ImageExportInfo object 00211 std::auto_ptr<Encoder> encoder( const ImageExportInfo & info ); 00212 00213 00214 /********************************************************/ 00215 /* */ 00216 /* ImageImportInfo */ 00217 /* */ 00218 /********************************************************/ 00219 00220 /** \brief Argument object for the function importImage(). 00221 See \ref importImage() for a usage example. This object must be 00222 used to read an image from disk and enquire about its properties. 00223 00224 <b>\#include</b> "<a href="imageinfo_8hxx-source.html">vigra/imageinfo.hxx</a>"<br> 00225 Namespace: vigra 00226 **/ 00227 class ImageImportInfo 00228 { 00229 public: 00230 enum PixelType { UINT8, INT16, INT32, FLOAT, DOUBLE }; 00231 00232 /** Construct ImageImportInfo object. 00233 00234 The image with the given filename is read into memory. 00235 The file type will be determined by the first few bytes of the 00236 file (magic number). Recognized file types: 00237 00238 <DL> 00239 <DT>"BMP"<DD> Microsoft Windows bitmap image file. 00240 <DT>"JPEG"<DD> Joint Photographic Experts Group JFIF format 00241 (only available if libjpeg is installed). 00242 <DT>"GIF"<DD> CompuServe graphics interchange format; 8-bit color. 00243 <DT>"PNG"<DD> Portable Network Graphics 00244 (only available if libpng is installed). 00245 <DT>"PBM"<DD> Portable bitmap format (black and white). 00246 <DT>"PGM"<DD> Portable graymap format (gray scale). 00247 <DT>"PNM"<DD> Portable anymap. 00248 <DT>"PPM"<DD> Portable pixmap format (color). 00249 <DT>"SUN"<DD> SUN Rasterfile. 00250 <DT>"TIFF"<DD> Tagged Image File Format. 00251 (only available if libtiff is installed.) 00252 <DT>"VIFF"<DD> Khoros Visualization image file. 00253 </DL> 00254 **/ 00255 ImageImportInfo( const char * ); 00256 00257 const char * getFileName() const; 00258 00259 /** Get the file type of the image associated with this 00260 info object. 00261 00262 See ImageImportInfo::ImageImportInfo for a list of the 00263 available file types. 00264 **/ 00265 const char * getFileType() const; 00266 00267 /** Get width of the image. 00268 **/ 00269 int width() const; 00270 00271 /** Get height of the image. 00272 **/ 00273 int height() const; 00274 00275 /** Get the number bands in the image. 00276 **/ 00277 int numBands() const; 00278 00279 /** Get size of the image. 00280 **/ 00281 Size2D size() const; 00282 00283 /** Returns true if the image is gray scale. 00284 **/ 00285 bool isGrayscale() const; 00286 00287 /** Returns true if the image is colored (RGB). 00288 **/ 00289 bool isColor() const; 00290 00291 /** Query the pixel type of the image. 00292 00293 Possible values are: 00294 <DL> 00295 <DT>"UINT8"<DD> 8-bit unsigned integer (unsigned char) 00296 <DT>"INT16"<DD> 16-bit signed integer (short) 00297 <DT>"INT32"<DD> 32-bit signed integer (long) 00298 <DT>"FLOAT"<DD> 32-bit floating point (float) 00299 <DT>"DOUBLE"<DD> 64-bit floating point (double) 00300 </DL> 00301 **/ 00302 const char * getPixelType() const; 00303 00304 /// deprecated: use getPixelType() 00305 PixelType pixelType() const; 00306 00307 /** Returns true if the image has 1 byte per pixel (gray) or 00308 3 bytes per pixel (RGB). 00309 **/ 00310 bool isByte() const; 00311 00312 /** Returns the image resolution in horizontal direction 00313 **/ 00314 float getXResolution() const; 00315 00316 /** Returns the image resolution in vertical direction 00317 **/ 00318 float getYResolution() const; 00319 00320 private: 00321 std::string m_filename, m_filetype, m_pixeltype; 00322 int m_width, m_height, m_num_bands; 00323 float m_x_res, m_y_res; 00324 }; 00325 00326 // return a decoder for a given ImageImportInfo object 00327 std::auto_ptr<vigra::Decoder> decoder( const ImageImportInfo & info ); 00328 00329 } // namespace vigra 00330 00331 #endif // VIGRA_IMAGEINFO_HXX
© Ullrich Köthe (koethe@informatik.uni-hamburg.de) |
html generated using doxygen and Python
|