[ VIGRA Homepage | Function Index | Class Index | Namespaces | File List | Main Page ]

sifImport.hxx
1/************************************************************************/
2/* */
3/* Copyright 2010 by Joachim Schleicher and Ullrich Koethe */
4/* */
5/* This file is part of the VIGRA computer vision library. */
6/* The VIGRA Website is */
7/* http://hci.iwr.uni-heidelberg.de/vigra/ */
8/* Please direct questions, bug reports, and contributions to */
9/* ullrich.koethe@iwr.uni-heidelberg.de or */
10/* vigra@informatik.uni-hamburg.de */
11/* */
12/* Permission is hereby granted, free of charge, to any person */
13/* obtaining a copy of this software and associated documentation */
14/* files (the "Software"), to deal in the Software without */
15/* restriction, including without limitation the rights to use, */
16/* copy, modify, merge, publish, distribute, sublicense, and/or */
17/* sell copies of the Software, and to permit persons to whom the */
18/* Software is furnished to do so, subject to the following */
19/* conditions: */
20/* */
21/* The above copyright notice and this permission notice shall be */
22/* included in all copies or substantial portions of the */
23/* Software. */
24/* */
25/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND */
26/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES */
27/* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND */
28/* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT */
29/* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, */
30/* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING */
31/* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR */
32/* OTHER DEALINGS IN THE SOFTWARE. */
33/* */
34/************************************************************************/
35
36
37/*
38 * Opens an Andor .sif file as MultiImageView.
39 * The width, height and number of images are extracted
40 * from the ASCII encoded variable length header.
41 *
42 * Based on the Java-Code from
43 * http://rsb.info.nih.gov/ij/plugins/open-sif.html
44 * written by
45 * L. Stirling Churchman (stirling at stanford.edu)
46 * Philippe Carl (pcarl at uni-muenster.de)
47 * Yoshiyuki Arai (arai at phys1.med.osaka-u.ac.jp)
48 *
49 * Currently tested SIF versions: 4.16.12005.0
50 * 4.16.30001.0
51 * 4. 6. 3.0
52*/
53
54#ifndef VIGRA_SIFIMPORT_HXX
55#define VIGRA_SIFIMPORT_HXX
56
57#include <fstream>
58#include <cstring>
59#include <cstddef>
60#include <vector>
61#include "multi_array.hxx"
62#include "array_vector.hxx"
63
64namespace vigra {
65
66
67 /** \addtogroup VigraSIFImport Import of Images from Andor Cameras
68
69 Read an Andor SIF file into a MultiArrayView.
70*/
71//@{
72
73/********************************************************/
74/* */
75/* SIFImportInfo */
76/* */
77/********************************************************/
78/** \brief Extracts image properties from an Andor SIF file header.
79
80See \ref readSIF() for a usage example. This object must be
81used to read the image header of an Andor SIF file
82and enquire its properties.
83
84<b>\#include</b> <vigra/sifImport.hxx><br>
85Namespace: vigra
86*/
88{
89 public:
90 /** Construct SIFImportInfo object.
91
92 The header of the Andor SIF file \a filename is accessed to
93 read the image properties.
94
95 \code
96 SIFImportInfo info(filename);
97 \endcode
98 */
99 VIGRA_EXPORT SIFImportInfo(const char* filename);
100
101 /** Get the width in pixels.
102 */
103 VIGRA_EXPORT int width() const;
104
105 /** Get the height in pixels.
106 */
107 VIGRA_EXPORT int height() const;
108
109 /** Get the stacksize, that is the number of
110 images contained in the dataset.
111 */
112 VIGRA_EXPORT int stacksize() const;
113
114 /** Get the number of dimensions of the dataset represented by this info object.
115 */
116 VIGRA_EXPORT MultiArrayIndex numDimensions() const;
117
118 /** Get the shape of the dataset represented by this info object.
119 */
120 VIGRA_EXPORT ArrayVector<size_t> const & shape() const;
121
122 /** Get the shape (length) of the dataset along dimension \a dim.
123 */
124 VIGRA_EXPORT MultiArrayIndex shapeOfDimension(const int dim) const;
125
126 /** Get the offset to the beginning of the actual data.
127 Everything before this point belongs to the
128 variable length header.
129 */
130 VIGRA_EXPORT std::ptrdiff_t getOffset() const;
131
132 /** Get the filename of this SIF object.
133 */
134 VIGRA_EXPORT const char * getFileName() const;
135
136 /** Output all information such as shutter, Temperature etc.
137 as human readable output.
138
139 <b> Usage:</b>
140
141 <b>\#include</b> <vigra/sifImport.hxx><br>
142 Namespace: vigra
143
144 \code
145 SIFImportInfo info(filename);
146 std::cout << info << std::endl; // print infos to the console
147
148 \endcode
149 */
150 VIGRA_EXPORT friend std::ostream& operator<<(std::ostream& os, const SIFImportInfo& info);
151
152 private:
153 const char* m_filename;
154 ArrayVector<size_t> m_dims;
155 std::ptrdiff_t m_offset;
156 int mod;
157 int left, right, bottom, top;
158 int xbin, ybin, xres, yres;
159 int headerlen;
160 double readout;
161 double temperature1, temperature2;
162 long long d;
163 std::string cycleTime, temperature, exposureTime, EMGain,
164 verticalShiftSpeed, version, model, originalFilename, preAmpGain;
165 size_t filesize;
166
167};
168
169
170
171
172 /** \brief Read the image data specified by the given \ref vigra::SIFImportInfo object
173 and write them into the given 'array'.
174
175 The array must have the correct number of dimensions and shape for the dataset
176 represented by 'info'.
177
178 <b> Declaration:</b>
179
180 \code
181 namespace vigra {
182 void
183 readSIF(const SIFImportInfo &info, MultiArrayView<3, float> array);
184 }
185 \endcode
186
187 <b> Usage:</b>
188
189 <b>\#include</b> <vigra/sifImport.hxx><br>
190 Namespace: vigra
191
192 \code
193 SIFImportInfo info(filename);
194
195 // create a 3D array of appropriate size
196 typedef MultiArray<3, float>::difference_type Shape;
197 MultiArray<3, float> in(Shape(info.width(), info.height(), info.stacksize()));
198
199 readSIF(info, in);
200 \endcode
201*/
202VIGRA_EXPORT void readSIF(const SIFImportInfo &info, MultiArrayView<3, float> array);
203
204template <unsigned int N, class T, class S>
206{
207 vigra_precondition(false, "readSIF(): Destination array must be MultiArrayView<3, float>.");
208}
209
210inline void readSIF(const SIFImportInfo &info, MultiArrayView<3, float, UnstridedArrayTag> array)
211{
212 readSIF(info, MultiArrayView<3, float>(array));
213}
214
215/**
216 \brief Read parts of the image data from an Andor SIF file specified with an SIFImportInfo object
217 and write them into the MultiArray array.
218
219 \code
220 SIFImportInfo info(filename);
221
222 // create a 3D array of appropriate size
223 MultiArray<3, float> in(Shape3(info.width(), info.height(), 1));
224
225 readBlock(info, Shape3(0,0,0), Shape3(w,h,1), im); // read the first frame only
226
227 \endcode
228*/
229VIGRA_EXPORT void readSIFBlock(const SIFImportInfo &info, Shape3 offset, Shape3 shape, MultiArrayView<3, float> array);
230
231template <unsigned int N, class T, class S>
232void readSIFBlock(const SIFImportInfo &, Shape3, Shape3, MultiArrayView<N, T, S>)
233{
234 vigra_precondition(false, "readSIFBlock(): Destination array must be MultiArrayView<3, float>.");
235}
236
237inline void readSIFBlock(const SIFImportInfo &info, Shape3 offset, Shape3 shape, MultiArrayView<3, float, UnstridedArrayTag> array)
238{
239 readSIFBlock(info, offset, shape, MultiArrayView<3, float>(array));
240}
241
242VIGRA_EXPORT std::ostream& operator<<(std::ostream& os, const SIFImportInfo& info);
243
244//@}
245
246} // namespace vigra
247
248#endif // VIGRA_SIFIMPORT_HXX
Definition array_vector.hxx:514
Base class for, and view to, MultiArray.
Definition multi_array.hxx:705
Extracts image properties from an Andor SIF file header.
Definition sifImport.hxx:88
SIFImportInfo(const char *filename)
MultiArrayIndex numDimensions() const
const char * getFileName() const
int stacksize() const
MultiArrayIndex shapeOfDimension(const int dim) const
ArrayVector< size_t > const & shape() const
std::ptrdiff_t getOffset() const
friend std::ostream & operator<<(std::ostream &os, const SIFImportInfo &info)
void readSIFBlock(const SIFImportInfo &info, Shape3 offset, Shape3 shape, MultiArrayView< 3, float > array)
Read parts of the image data from an Andor SIF file specified with an SIFImportInfo object and write ...
void readSIF(const SIFImportInfo &info, MultiArrayView< 3, float > array)
Read the image data specified by the given SIFImportInfo object and write them into the given 'array'...
std::ptrdiff_t MultiArrayIndex
Definition multi_fwd.hxx:60

© Ullrich Köthe (ullrich.koethe@iwr.uni-heidelberg.de)
Heidelberg Collaboratory for Image Processing, University of Heidelberg, Germany

html generated using doxygen and Python
vigra 1.12.1 (Thu Feb 27 2025)