casacore
Loading...
Searching...
No Matches
CurvedImage2D.h
Go to the documentation of this file.
1// # CurvedImage2D.h: An image crosscut based on a curve in a plane
2// # Copyright (C) 2003
3// # Associated Universities, Inc. Washington DC, USA.
4// #
5// # This library is free software; you can redistribute it and/or modify it
6// # under the terms of the GNU Library General Public License as published by
7// # the Free Software Foundation; either version 2 of the License, or (at your
8// # option) any later version.
9// #
10// # This library is distributed in the hope that it will be useful, but WITHOUT
11// # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12// # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13// # License for more details.
14// #
15// # You should have received a copy of the GNU Library General Public License
16// # along with this library; if not, write to the Free Software Foundation,
17// # Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18// #
19// # Correspondence concerning AIPS++ should be addressed as follows:
20// # Internet email: casa-feedback@nrao.edu.
21// # Postal address: AIPS++ Project Office
22// # National Radio Astronomy Observatory
23// # 520 Edgemont Road
24// # Charlottesville, VA 22903-2475 USA
25
26#ifndef IMAGES_CURVEDIMAGE2D_H
27#define IMAGES_CURVEDIMAGE2D_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/images/Images/ImageInterface.h>
32
33namespace casacore { // # NAMESPACE CASACORE - BEGIN
34
35// # Forward Declarations
36template <class T>
37class CurvedLattice2D;
38template <class T>
40class PixelCurve1D;
41
42// <summary>
43// An image crosscut based on a curve in a plane.
44// </summary>
45//
46// <use visibility=export>
47//
48// <reviewed reviewer="" date="" tests="tCurvedImage2D.cc">
49// </reviewed>
50//
51// <prerequisite>
52// <li> <linkto class=ImageInterface>ImageInterface</linkto>
53// <li> <linkto class=CurvedLattice2D>CurvedLattice2D</linkto>
54// </prerequisite>
55//
56// <synopsis>
57// Class CurvedImage2D can be used to make a crosscut through an image
58// with a dimensionality >= 2. The dimensionality of the resulting image
59// is one less.
60// The crosscut is based on a curve defined by a
61// <linkto class=PixelCurve1D>PixelCurve1D</linkto> object. The curve
62// can be any 1-dim function (e.g. straight line, spline)
63// supported by the Functionals module. The curve must be in one of the
64// main planes of the image as defined by the axes arguments in the
65// constructor.
66// <br>For example: in an RA-DEC-FREQ image a straight line can be
67// defined in the RA-DEC plane (axis1=0, axis2=1) from blc {0,0) to
68// trc (511,511). The crosscut will follow this line, so the result is
69// a 2-dim image with axes 'line' and FREQ. So it contains the spectrum
70// for all points on the line (points (0,0), (1,1) ... (511,511)).
71// <br>In this example the line only contains exact grid points. In
72// practice that usually won't be case, so interpolation has to be done.
73// This is done by a class derived from
74// <linkto class=CLInterpolator2D>CLInterpolator2D</linkto>, so any
75// interpolation scheme is possible. Currently only the nearest neighbour
76// scheme is implemented (<linkto class=CLIPNearest2D>CLIPNearest2D</linkto>).
77// </synopsis>
78//
79// <example>
80// The following example uses a 3-dim image.
81// It makes a crosscut using a line from the blc to the trc in the XY plane.
82// The number of points on the line is the maximum of the number of points
83// in X and Y.
84// <srcblock>
85// // Open an image.
86// PagedImage<Float> image("name.img");
87// // Make a straight line from (0,0) to the trc.
88// IPosition shp = lat.shape();
89// Int xtop = shp(0);
90// Int ytop = shp(1);
91// Int nr = xtop;
92// if (nr > ytop) nr = ytop;
93// PixelCurve1D pc(0, 0, xtop-1, ytop-1, nr);
94// // Create the crosscut image.
95// // The new axis (the curve axis) is the first axis in the result.
96// CurvedImage2D<Float> clat(image, CLIPNearest2D<Float>(), pc, 0, 1, 0);
97// </srcblock>
98// Note that in the general case the line (or any curve) won't be from
99// the blc to the trc. In fact, it is possible to give any starting and
100// end point and any number of points on the curve.
101// </example>
102//
103// <motivation>
104// Users like to view arbitrary image crosscuts.
105// </motivation>
106//
107// # <todo asof="1998/02/09">
108// # </todo>
109
110template <class T>
111class CurvedImage2D : public ImageInterface<T> {
112 public:
113 // The default constructor
115
116 // Take a curved slice from the given image.
117 // The <linkto class=PixelCurve1D>PixelCurve1D</linkto> object defines
118 // the curve in one of the planes of the image. The arguments axis1
119 // and axis2 define the plane the curve is in.
120 // The <linkto class=CLInterpolator2D>CLInterpolator2D</linkto> object
121 // defines the interpolation scheme for pixels that are not on grid points.
122 // An example is CLIPNearest2D which takes the nearest neighbour.
123 // The dimensionality of the CurvedImage2D is one less than the
124 // dimensionality of the given image. Two axes (axis1 and axis2) are
125 // replaced by the new axis representing the curve. The argument
126 // curveAxis defines the axis number of the new axis. It defaults to the
127 // last axis.
128 // An exception is thrown if the dimensionality of the input image is < 2
129 // or if the given axes numbers are too high.
130 // Note that the output CoordinateSystem of the CurvedImage is just a dummy
131 // LinearCoordinate at this point. The values are all arbitrary.
133 uInt axis1, uInt axis2, Int curveAxis = -1);
134
135 // Copy constructor (reference semantics).
137
138 virtual ~CurvedImage2D();
139
140 // Assignment (reference semantics).
142
143 // Make a copy of the object (reference semantics).
144 // <group>
145 virtual ImageInterface<T>* cloneII() const;
146 // </group>
147
148 // Get the image type (returns name of derived class).
149 virtual String imageType() const;
150
151 // Is the CurvedImage2D masked?
152 // It is if its parent image is masked.
153 virtual Bool isMasked() const;
154
155 // Does the image object have a pixelmask?
156 // It does if its parent has a pixelmask.
157 virtual Bool hasPixelMask() const;
158
159 // Get access to the pixelmask in use (thus to the pixelmask of the parent).
160 // An exception is thrown if the parent does not have a pixelmask.
161 // <group>
162 virtual const Lattice<Bool>& pixelMask() const;
164 // </group>
165
166 // Get the region used (always returns 0).
167 virtual const LatticeRegion* getRegionPtr() const;
168
169 // A CurvedImage2D is not persistent.
170 virtual Bool isPersistent() const;
171
172 // Is the CurvedImage2D paged to disk?
173 virtual Bool isPaged() const;
174
175 // An CurvedImage2D is not writable
176 virtual Bool isWritable() const;
177
178 // Returns the shape of the CurvedImage2D
179 virtual IPosition shape() const;
180
181 // This function returns the recommended maximum number of pixels to
182 // include in the cursor of an iterator.
183 virtual uInt advisedMaxPixels() const;
184
185 // Function which changes the shape of the CurvedImage2D.
186 // Throws an exception as resizing an CurvedImage2D is not possible.
187 virtual void resize(const TiledShape& newShape);
188
189 // Return the name of the parent ImageInterface object.
190 virtual String name(Bool stripPath = False) const;
191
192 // Check class invariants.
193 virtual Bool ok() const;
194
195 // Get access to the attribute handler (of the parent image).
196 // If a handler keyword does not exist yet, it is created if
197 // <src>createHandler</src> is set.
198 // Otherwise the handler is empty and no groups can be created for it.
199 virtual ImageAttrHandler& attrHandler(Bool createHandler = False);
200
201 // Do the actual getting of an array of values.
202 virtual Bool doGetSlice(Array<T>& buffer, const Slicer& section);
203
204 // Putting data is not possible.
205 virtual void doPutSlice(const Array<T>& sourceBuffer, const IPosition& where,
206 const IPosition& stride);
207
208 // Get a section of the mask.
209 virtual Bool doGetMaskSlice(Array<Bool>& buffer, const Slicer& section);
210
211 // This function is used by the LatticeIterator class to generate an
212 // iterator of the correct type for this Lattice. Not recommended
213 // for general use.
214 virtual LatticeIterInterface<T>* makeIter(const LatticeNavigator& navigator, Bool useRef) const;
215
216 // Get the best cursor shape.
217 virtual IPosition doNiceCursorShape(uInt maxPixels) const;
218
219 // Handle the (un)locking and syncing, etc.
220 // <group>
221 virtual Bool lock(FileLocker::LockType, uInt nattempts);
222 virtual void unlock();
224 virtual void resync();
225 virtual void flush();
226 virtual void tempClose();
227 virtual void reopen();
228 // </group>
229
230 private:
231 // # itsImagePtr points to the parent image.
234
235 // # Make members of parent class known.
236 public:
237 using ImageInterface<T>::logger;
238
239 protected:
241};
242
243} // namespace casacore
244
245#ifndef CASACORE_NO_AUTO_TEMPLATES
246#include <casacore/images/Images/CurvedImage2D.tcc>
247#endif // # CASACORE_NO_AUTO_TEMPLATES
248#endif
CurvedImage2D()
The default constructor.
virtual const Lattice< Bool > & pixelMask() const
Get access to the pixelmask in use (thus to the pixelmask of the parent).
virtual Bool doGetMaskSlice(Array< Bool > &buffer, const Slicer &section)
Get a section of the mask.
virtual uInt advisedMaxPixels() const
This function returns the recommended maximum number of pixels to include in the cursor of an iterato...
virtual void reopen()
Explicitly reopen the temporarily closed lattice.
CurvedLattice2D< T > * itsCurLatPtr
virtual IPosition shape() const
Returns the shape of the CurvedImage2D.
virtual IPosition doNiceCursorShape(uInt maxPixels) const
Get the best cursor shape.
virtual Bool hasLock(FileLocker::LockType) const
virtual LatticeIterInterface< T > * makeIter(const LatticeNavigator &navigator, Bool useRef) const
This function is used by the LatticeIterator class to generate an iterator of the correct type for th...
virtual Bool hasPixelMask() const
Does the image object have a pixelmask?
virtual const LatticeRegion * getRegionPtr() const
Get the region used (always returns 0).
virtual String imageType() const
Get the image type (returns name of derived class).
virtual Bool isWritable() const
An CurvedImage2D is not writable.
virtual Bool isPaged() const
Is the CurvedImage2D paged to disk?
virtual Bool ok() const
Check class invariants.
ImageInterface< T > * itsImagePtr
virtual ImageInterface< T > * cloneII() const
Make a copy of the object (reference semantics).
virtual Bool isMasked() const
Is the CurvedImage2D masked?
virtual Bool doGetSlice(Array< T > &buffer, const Slicer &section)
Do the actual getting of an array of values.
virtual Bool lock(FileLocker::LockType, uInt nattempts)
Handle the (un)locking and syncing, etc.
virtual void tempClose()
Temporarily close the lattice.
virtual void resync()
Resynchronize the Lattice object with the lattice file.
virtual void doPutSlice(const Array< T > &sourceBuffer, const IPosition &where, const IPosition &stride)
Putting data is not possible.
CurvedImage2D(const ImageInterface< T > &, const CLInterpolator2D< T > &, const PixelCurve1D &, uInt axis1, uInt axis2, Int curveAxis=-1)
Take a curved slice from the given image.
virtual ImageAttrHandler & attrHandler(Bool createHandler=False)
Get access to the attribute handler (of the parent image).
virtual void flush()
Flush the data (but do not unlock).
virtual void resize(const TiledShape &newShape)
Function which changes the shape of the CurvedImage2D.
virtual Lattice< Bool > & pixelMask()
virtual void unlock()
virtual Bool isPersistent() const
A CurvedImage2D is not persistent.
CurvedImage2D(const CurvedImage2D< T > &other)
Copy constructor (reference semantics).
CurvedImage2D< T > & operator=(const CurvedImage2D< T > &other)
Assignment (reference semantics).
virtual String name(Bool stripPath=False) const
Return the name of the parent ImageInterface object.
LockType
Define the possible lock types.
Definition FileLocker.h:89
void setCoordsMember(const CoordinateSystem &coords)
Set the coordinate system variable.
LoggerHolder & logger()
Get access to the LoggerHolder.
String: the storage and methods of handling collections of characters.
Definition String.h:355
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
const Bool False
Definition aipstype.h:42
unsigned int uInt
Definition aipstype.h:49
int Int
Definition aipstype.h:48
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40