[ VIGRA Homepage | Function Index | Class Index | Namespaces | File List | Main Page ]
vigra/sifImport.hxx | ![]() |
00001 /************************************************************************/ 00002 /* */ 00003 /* Copyright 2010 by Joachim Schleicher and Ullrich Koethe */ 00004 /* */ 00005 /* This file is part of the VIGRA computer vision library. */ 00006 /* The VIGRA Website is */ 00007 /* http://hci.iwr.uni-heidelberg.de/vigra/ */ 00008 /* Please direct questions, bug reports, and contributions to */ 00009 /* ullrich.koethe@iwr.uni-heidelberg.de or */ 00010 /* vigra@informatik.uni-hamburg.de */ 00011 /* */ 00012 /* Permission is hereby granted, free of charge, to any person */ 00013 /* obtaining a copy of this software and associated documentation */ 00014 /* files (the "Software"), to deal in the Software without */ 00015 /* restriction, including without limitation the rights to use, */ 00016 /* copy, modify, merge, publish, distribute, sublicense, and/or */ 00017 /* sell copies of the Software, and to permit persons to whom the */ 00018 /* Software is furnished to do so, subject to the following */ 00019 /* conditions: */ 00020 /* */ 00021 /* The above copyright notice and this permission notice shall be */ 00022 /* included in all copies or substantial portions of the */ 00023 /* Software. */ 00024 /* */ 00025 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND */ 00026 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES */ 00027 /* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND */ 00028 /* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT */ 00029 /* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, */ 00030 /* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING */ 00031 /* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR */ 00032 /* OTHER DEALINGS IN THE SOFTWARE. */ 00033 /* */ 00034 /************************************************************************/ 00035 00036 00037 /* 00038 * Opens an Andor .sif file as MultiImageView. 00039 * The width, height and number of images are extracted 00040 * from the ASCII encoded variable length header. 00041 * 00042 * Based on the Java-Code from 00043 * http://rsb.info.nih.gov/ij/plugins/open-sif.html 00044 * written by 00045 * L. Stirling Churchman (stirling at stanford.edu) 00046 * Philippe Carl (pcarl at uni-muenster.de) 00047 * Yoshiyuki Arai (arai at phys1.med.osaka-u.ac.jp) 00048 * 00049 * Currently tested SIF versions: 4.16.12005.0 00050 * 4.16.30001.0 00051 * 4. 6. 3.0 00052 */ 00053 00054 #ifndef VIGRA_SIFIMPORT_HXX 00055 #define VIGRA_SIFIMPORT_HXX 00056 00057 #include <fstream> 00058 #include <cstring> 00059 #include <cstddef> 00060 #include <vector> 00061 #include "vigra/multi_array.hxx" 00062 #include "vigra/array_vector.hxx" 00063 00064 namespace vigra { 00065 00066 00067 /** \addtogroup VigraSIFImport Import of Images from Andor Cameras 00068 00069 Read an Andor SIF file into a MultiArrayView. 00070 */ 00071 //@{ 00072 00073 /********************************************************/ 00074 /* */ 00075 /* SIFImportInfo */ 00076 /* */ 00077 /********************************************************/ 00078 /** \brief Extracts image properties from an Andor SIF file header. 00079 00080 See \ref readSIF() for a usage example. This object must be 00081 used to read the image header of an Andor SIF file 00082 and enquire its properties. 00083 00084 <b>\#include</b> <vigra/sifImport.hxx><br> 00085 Namespace: vigra 00086 */ 00087 class SIFImportInfo 00088 { 00089 public: 00090 /** Construct SIFImportInfo object. 00091 00092 The header of the Andor SIF file \a filename is accessed to 00093 read the image properties. 00094 00095 \code 00096 SIFImportInfo info(filename); 00097 \endcode 00098 */ 00099 VIGRA_EXPORT SIFImportInfo(const char* filename); 00100 00101 /** Get the width in pixels. 00102 */ 00103 VIGRA_EXPORT int width() const; 00104 00105 /** Get the height in pixels. 00106 */ 00107 VIGRA_EXPORT int height() const; 00108 00109 /** Get the stacksize, that is the number of 00110 images contained in the dataset. 00111 */ 00112 VIGRA_EXPORT int stacksize() const; 00113 00114 /** Get the number of dimensions of the dataset represented by this info object. 00115 */ 00116 VIGRA_EXPORT MultiArrayIndex numDimensions() const; 00117 00118 /** Get the shape of the dataset represented by this info object. 00119 */ 00120 VIGRA_EXPORT ArrayVector<size_t> const & shape() const; 00121 00122 /** Get the shape (length) of the dataset along dimension \a dim. 00123 */ 00124 VIGRA_EXPORT MultiArrayIndex shapeOfDimension(const int dim) const; 00125 00126 /** Get the offset to the beginning of the actual data. 00127 Everything before this point belongs to the 00128 variable length header. 00129 */ 00130 VIGRA_EXPORT std::ptrdiff_t getOffset() const; 00131 00132 /** Get the filename of this SIF object. 00133 */ 00134 VIGRA_EXPORT const char * getFileName() const; 00135 00136 /** Output all information such as shutter, Temperature etc. 00137 as human readable output. 00138 00139 <b> Usage:</b> 00140 00141 <b>\#include</b> <vigra/sifImport.hxx><br> 00142 Namespace: vigra 00143 00144 \code 00145 SIFImportInfo info(filename); 00146 std::cout << info << std::endl; // print infos to the console 00147 00148 \endcode 00149 */ 00150 VIGRA_EXPORT friend std::ostream& operator<<(std::ostream& os, const SIFImportInfo& info); 00151 00152 private: 00153 const char* m_filename; 00154 ArrayVector<size_t> m_dims; 00155 std::ptrdiff_t m_offset; 00156 int mod; 00157 int left, right, bottom, top; 00158 int xbin, ybin, xres, yres; 00159 int headerlen; 00160 double readout; 00161 double temperature1, temperature2; 00162 long long d; 00163 std::string cycleTime, temperature, exposureTime, EMGain, 00164 verticalShiftSpeed, version, model, originalFilename, preAmpGain; 00165 size_t filesize; 00166 00167 }; 00168 00169 00170 00171 00172 /** \brief Read the image data specified by the given \ref vigra::SIFImportInfo object 00173 and write them into the given 'array'. 00174 00175 The array must have the correct number of dimensions and shape for the dataset 00176 represented by 'info'. 00177 00178 <b> Declaration:</b> 00179 00180 \code 00181 namespace vigra { 00182 void 00183 readSIF(const SIFImportInfo &info, MultiArrayView<3, float, UnstridedArrayTag> array); 00184 } 00185 \endcode 00186 00187 <b> Usage:</b> 00188 00189 <b>\#include</b> <vigra/sifImport.hxx><br> 00190 Namespace: vigra 00191 00192 \code 00193 SIFImportInfo info(filename); 00194 00195 // create a 3D array of appropriate size 00196 typedef MultiArray<3, float>::difference_type Shape; 00197 MultiArray<3, float> in(Shape(info.width(), info.height(), info.stacksize())); 00198 00199 readSIF(info, in); 00200 \endcode 00201 */ 00202 VIGRA_EXPORT void readSIF(const SIFImportInfo &info, MultiArrayView<3, float, UnstridedArrayTag> array); 00203 00204 /** 00205 \brief Read parts of the image data from an Andor SIF file specified with an SIFImportinfo object 00206 and write them into the MultiArray array. 00207 00208 \code 00209 SIFImportInfo info(filename); 00210 00211 // create a 3D array of appropriate size 00212 MultiArray<3, float> in(Shape3(info.width(), info.height(), 1)); 00213 00214 readBlock(info, Shape3(0,0,0), Shape3(w,h,1), im); // read the first frame only 00215 00216 \endcode 00217 */ 00218 VIGRA_EXPORT void readSIFBlock(const SIFImportInfo &info, Shape3 offset, Shape3 shape, MultiArrayView<3, float, UnstridedArrayTag> array); 00219 00220 VIGRA_EXPORT std::ostream& operator<<(std::ostream& os, const SIFImportInfo& info); 00221 00222 //@} 00223 00224 } // namespace vigra 00225 00226 #endif // VIGRA_SIFIMPORT_HXX
© Ullrich Köthe (ullrich.koethe@iwr.uni-heidelberg.de) |
html generated using doxygen and Python
|