ome-files 0.1.0

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List

ImageJMetadata.h
1 /*
2 * #%L
3 * OME-FILES C++ library for image IO.
4 * Copyright © 2006 - 2015 Open Microscopy Environment:
5 * - Massachusetts Institute of Technology
6 * - National Institutes of Health
7 * - University of Dundee
8 * - Board of Regents of the University of Wisconsin-Madison
9 * - Glencoe Software, Inc.
10 * %%
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions are met:
13 *
14 * 1. Redistributions of source code must retain the above copyright notice,
15 * this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright notice,
17 * this list of conditions and the following disclaimer in the documentation
18 * and/or other materials provided with the distribution.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
24 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
31 *
32 * The views and conclusions contained in the software and documentation are
33 * those of the authors and should not be interpreted as representing official
34 * policies, either expressed or implied, of any organization.
35 * #L%
36 */
37
38 #ifndef OME_FILES_TIFF_IMAGEJMETADATA_H
39 #define OME_FILES_TIFF_IMAGEJMETADATA_H
40
41 #include <map>
42 #include <vector>
43 #include <sstream>
44 #include <string>
45
46 #include <ome/files/Types.h>
47
48 namespace ome
49 {
50 namespace files
51 {
52 namespace tiff
53 {
54
55 class IFD;
56
60 struct ImageJMetadata
61 {
63 std::map<std::string, std::string> map;
65 std::vector<uint32_t> counts;
67 std::vector<uint8_t> data;
69 dimension_size_type images;
71 dimension_size_type slices;
73 dimension_size_type frames;
75 dimension_size_type channels;
77 std::string unit;
79 double spacing;
81 double finterval;
83 dimension_size_type xorigin;
85 dimension_size_type yorigin;
87 std::string mode;
89 bool loop;
90
97 ImageJMetadata(const IFD& ifd);
98
108 static
109 std::map<std::string,std::string>
110 parse_imagedescription(const std::string& description);
111
112 protected:
120 static
121 void
122 parse_value_error(const std::string& key,
123 const std::string& value);
124
135 template<typename T>
136 void
137 parse_value(const std::string& key,
138 T& value)
139 {
140 std::map<std::string,std::string>::const_iterator i = map.find(key);
141 if (i != map.end())
142 {
143 try
144 {
145 std::istringstream is(i->second);
146 is.imbue(std::locale::classic());
147 is.exceptions(std::ios::failbit);
148 is >> value;
149 }
150 catch (const std::ios_base::failure&)
151 {
152 parse_value_error(key, i->second);
153 }
154 }
155 }
156
167 void
168 parse_value(const std::string& key,
169 bool& value);
170
181 void
182 parse_value(const std::string& key,
183 std::string& value);
184
185 };
186
187 }
188 }
189 }
190
191 #endif // OME_FILES_TIFF_IMAGEJMETADATA_H
192
193 /*
194 * Local Variables:
195 * mode:C++
196 * End:
197 */
ome::files::tiff::ImageJMetadata::unit
std::string unit
Length unit name.
Definition: ImageJMetadata.h:77
ome::files::tiff::ImageJMetadata::ImageJMetadata
ImageJMetadata(const IFD &ifd)
Construct from an IFD.
Definition: ImageJMetadata.cpp:65
ome::files::tiff::ImageJMetadata::parse_imagedescription
static std::map< std::string, std::string > parse_imagedescription(const std::string &description)
Parse the TIFF ImageDescription field content.
Definition: ImageJMetadata.cpp:87
ome::files::tiff::ImageJMetadata::map
std::map< std::string, std::string > map
Map of key-value pairs from ImageDescription field.
Definition: ImageJMetadata.h:63
ome::files::tiff::ImageJMetadata::loop
bool loop
Loop animation(?).
Definition: ImageJMetadata.h:89
ome::files::dimension_size_type
std::size_t dimension_size_type
Size type for image dimensions.
Definition: Types.h:59
ome::files::tiff::ImageJMetadata::parse_value_error
static void parse_value_error(const std::string &key, const std::string &value)
Throw an exception on failing to parse a particular key value.
Definition: ImageJMetadata.cpp:137
ome::files::tiff::ImageJMetadata::xorigin
dimension_size_type xorigin
X origin.
Definition: ImageJMetadata.h:83
ome::files::tiff::ImageJMetadata::parse_value
void parse_value(const std::string &key, T &value)
Parse a key's value into a given type.
Definition: ImageJMetadata.h:137
ome::files::tiff::ImageJMetadata::slices
dimension_size_type slices
Slice count.
Definition: ImageJMetadata.h:71
ome::files::tiff::ImageJMetadata::channels
dimension_size_type channels
Channel count.
Definition: ImageJMetadata.h:75
ome
ome::files::tiff::ImageJMetadata::mode
std::string mode
Color mode.
Definition: ImageJMetadata.h:87
ome::files::tiff::ImageJMetadata::spacing
double spacing
Z spacing distance.
Definition: ImageJMetadata.h:79
ome::files::tiff::ImageJMetadata::data
std::vector< uint8_t > data
Content of ImageJMetaData field.
Definition: ImageJMetadata.h:67
ome::files::tiff::ImageJMetadata::images
dimension_size_type images
Total number of images.
Definition: ImageJMetadata.h:69
ome::files::tiff::ImageJMetadata::frames
dimension_size_type frames
Frame count.
Definition: ImageJMetadata.h:73
ome::files::tiff::ImageJMetadata::yorigin
dimension_size_type yorigin
Y origin.
Definition: ImageJMetadata.h:85
ome::files::tiff::ImageJMetadata::finterval
double finterval
Frame interval time.
Definition: ImageJMetadata.h:81
ome::files::tiff::IFD
Image File Directory (IFD).
Definition: IFD.h:71
ome::files::tiff::ImageJMetadata
ImageJ metadata from IFD tags.
Definition: ImageJMetadata.h:60
ome::files::tiff::ImageJMetadata::counts
std::vector< uint32_t > counts
Content of ImageJMetaDataByteCounts field.
Definition: ImageJMetadata.h:65