-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathImageMetaData.h
185 lines (143 loc) · 7.44 KB
/
ImageMetaData.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
//# ImageMetaData.h: Meta information for Images
//# Copyright (C) 2009
//# Associated Universities, Inc. Washington DC, USA.
//#
//# This library is free software; you can redistribute it and/or modify it
//# under the terms of the GNU Library General Public License as published by
//# the Free Software Foundation; either version 2 of the License, or (at your
//# option) any later version.
//#
//# This library is distributed in the hope that it will be useful, but WITHOUT
//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
//# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
//# License for more details.
//#
//# You should have received a copy of the GNU Library General Public License
//# along with this library; if not, write to the Free Software Foundation,
//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
//#
//# Correspondence concerning AIPS++ should be addressed as follows:
//# Internet email: [email protected].
//# Postal address: AIPS++ Project Office
//# National Radio Astronomy Observatory
//# 520 Edgemont Road
//# Charlottesville, VA 22903-2475 USA
//#
//# $Id: ImageMetaData.h 21130 2011-10-18 07:39:05Z gervandiepen $
#ifndef IMAGES_IMAGEMETADATA_H
#define IMAGES_IMAGEMETADATA_H
#include <casacore/images/Images/ImageInterface.h>
#include <casacore/casa/aips.h>
namespace casacore { //# NAMESPACE CASACORE - BEGIN
// <summary>
// A class in which to store and allow read-only access to image metadata.
// </summary>
// <use visibility=export>
// <reviewed reviewer="" date="" tests="" demos="">
// </reviewed>
// <prerequisite>
// <li> <linkto class=ImageInterface>ImageInterface</linkto>
// </prerequisite>
// <etymology>
// The ImageMetaData class name is derived from its role as holding image metadata.
// </etymology>
// <synopsis>
// The ImageMetaData object is meant to allow access to image metadata (eg, shape,
// coordinate system info such as spectral and polarization axes numbers, etc).
// </synopsis>
// <example>
// Construct an object of this class by passing the associated image to the constructor.
// <srcblock>
// PagedImage<Float> myImage("myImage");
// ImageMetaData<Float> myImageMetaData(myImage);
// </srcblock>
// </example>
// <motivation>
// This class is meant to provide an object-oriented interface for accessing
// image metadata without polluting the ImageInterface and CoordinateSystem
// classes with these methods.
// </motivation>
// <todo>
// Merge ImageInfo class into this class.
// </todo>
class ImageMetaData {
public:
template <class T> ImageMetaData(const ImageInterface<T>& image) :
itsInfo(image.imageInfo()), itsUnits(image.units()),
itsCoordinates(image.coordinates()), itsShape(image.shape()) {}
// Get the axis number of the spectral axis of this image (0-based).
Int spectralAxisNumber() const;
// Get the number of channels in this image.
uInt nChannels() const;
// Is the specified channel number valid for this image?
Bool isChannelNumberValid(const uInt chan) const;
// Get the coordinate number of the spectral axis of this image (0-based). This
// is generally not the same as the axis number because the direction (eg RA, Dec)
// coordinate counts as only one coordinate, not two. Yes I know its confusing.
// Here's an example, say you have an image with axes, RA, Dec, Stokes, Frequency.
// The spectral coordinate number would be 2 since RA, Dec make up a single
// direction coordinate. But, the spectral axis number would be 3, because RA
// and Dec are counted seperately in this case. Its important (and very confusing)
// to be clear about this difference or things will break.
Int spectralCoordinateNumber() const;
// Does this image have a spectral (frequency) axis?
Bool hasSpectralAxis() const;
// Get the coordinate number of the polarization axis of this image (0-based). This
// is generally not the same as the axis number because the direction (eg RA, Dec)
// coordinate counts as only one coordinate, not two. Yes I know its confusing.
// Here's an example, say you have an image with axes, RA, Dec, Stokes, Frequency.
// The polarization coordinate number would be 1 since RA, Dec make up a single
// direction coordinate. But, the polarization axis number would be 2, because RA
// and Dec are counted seperately in this case. Its important (and very confusing)
// to be clear about this difference or things will break. Return -1
// if this image does not have a polarization axis.
Int polarizationCoordinateNumber() const;
// Get the axis number of the polarization axis of this image (0-based). Return -1
// if this image does not have a polarization axis.
Int polarizationAxisNumber() const;
// Does this image have a polarization axis?
Bool hasPolarizationAxis() const;
// Get the pixel number on the polarization axis of the specified stokes parameter.
// If the specified stokes parameter does not exist in the image, the value returned
// is not gauranteed to be anything other than outside the range of 0 to nStokes-1
// inclusive. Return -1 if the specified stokes parameter is not present or
// if this image does not have a polarization axis.
Int stokesPixelNumber(const String& stokesString) const;
// get the stokes parameter at the specified pixel value on the polarization axis.
// returns "" if the specified pixel is out of range or if no polarization axis.
String stokesAtPixel(const uInt pixel) const;
// Get the number of stokes parameters in this image.
uInt nStokes() const;
// is the specified stokes parameter present in the image?
Bool isStokesValid(const String& stokesString) const;
// Get the zero based direction coordinate number.
Int directionCoordinateNumber() const;
// does this image have a direction coordinate?
Bool hasDirectionCoordinate() const;
// Get the direction axes numbers for this image. Returns a two element
// Vector if there is a direction coordinate, if not returns a zero element
// vector.
Vector<Int> directionAxesNumbers() const;
// Get the shape of the direction axes. Returns a two element
// Vector if there is a direction coordinate, if not returns a zero element
// vector.
Vector<Int> directionShape() const;
// if the specified stokes parameter is valid. A message suitable for
// error notification is returned in the form of an in-out parameter
//if one or both of these is invalid.
Bool areChannelAndStokesValid(
String& message, const uInt chan, const String& stokesString
) const;
// Get beam volume if possible. Return true if beam area was determined.
Bool getBeamArea(Quantity& beamArea) const;
// Get the solid angle subtended by a direction pixel (eg ra,dec or lat, long)
// Return False if this value cannot be determined.
Bool getDirectionPixelArea(Quantity& pixelArea) const;
private:
const ImageInfo itsInfo;
const Unit itsUnits;
const CoordinateSystem& itsCoordinates;
const IPosition itsShape;
};
} //# NAMESPACE CASACORE - END
#endif