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
30//# Includes
31#include <casacore/casa/aips.h>
32#include <casacore/images/Images/ImageInterface.h>
33
34namespace casacore { //# NAMESPACE CASACORE - BEGIN
35
36//# Forward Declarations
37template <class T> class CurvedLattice2D;
38template <class T> class CLInterpolator2D;
39class PixelCurve1D;
40
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
110
111template <class T> class CurvedImage2D: public ImageInterface<T>
112{
113public:
114 // The default constructor
116
117 // Take a curved slice from the given image.
118 // The <linkto class=PixelCurve1D>PixelCurve1D</linkto> object defines
119 // the curve in one of the planes of the image. The arguments axis1
120 // and axis2 define the plane the curve is in.
121 // The <linkto class=CLInterpolator2D>CLInterpolator2D</linkto> object
122 // defines the interpolation scheme for pixels that are not on grid points.
123 // An example is CLIPNearest2D which takes the nearest neighbour.
124 // The dimensionality of the CurvedImage2D is one less than the
125 // dimensionality of the given image. Two axes (axis1 and axis2) are
126 // replaced by the new axis representing the curve. The argument
127 // curveAxis defines the axis number of the new axis. It defaults to the
128 // last axis.
129 // An exception is thrown if the dimensionality of the input image is < 2
130 // or if the given axes numbers are too high.
131 // Note that the output CoordinateSystem of the CurvedImage is just a dummy
132 // LinearCoordinate at this point. The values are all arbitrary.
134 const PixelCurve1D&, uInt axis1, uInt axis2,
135 Int curveAxis=-1);
136
137 // Copy constructor (reference semantics).
139
140 virtual ~CurvedImage2D();
141
142 // Assignment (reference semantics).
144
145 // Make a copy of the object (reference semantics).
146 // <group>
147 virtual ImageInterface<T>* cloneII() const;
148 // </group>
149
150 // Get the image type (returns name of derived class).
151 virtual String imageType() const;
152
153 // Is the CurvedImage2D masked?
154 // It is if its parent image is masked.
155 virtual Bool isMasked() const;
156
157 // Does the image object have a pixelmask?
158 // It does if its parent has a pixelmask.
159 virtual Bool hasPixelMask() const;
160
161 // Get access to the pixelmask in use (thus to the pixelmask of the parent).
162 // An exception is thrown if the parent does not have a pixelmask.
163 // <group>
164 virtual const Lattice<Bool>& pixelMask() const;
166 // </group>
167
168 // Get the region used (always returns 0).
169 virtual const LatticeRegion* getRegionPtr() const;
170
171 // A CurvedImage2D is not persistent.
172 virtual Bool isPersistent() const;
173
174 // Is the CurvedImage2D paged to disk?
175 virtual Bool isPaged() const;
176
177 // An CurvedImage2D is not writable
178 virtual Bool isWritable() const;
179
180 // Returns the shape of the CurvedImage2D
181 virtual IPosition shape() const;
182
183 // This function returns the recommended maximum number of pixels to
184 // include in the cursor of an iterator.
185 virtual uInt advisedMaxPixels() const;
186
187 // Function which changes the shape of the CurvedImage2D.
188 // Throws an exception as resizing an CurvedImage2D is not possible.
189 virtual void resize(const TiledShape& newShape);
190
191 // Return the name of the parent ImageInterface object.
192 virtual String name (Bool stripPath=False) const;
193
194 // Check class invariants.
195 virtual Bool ok() const;
196
197 // Get access to the attribute handler (of the parent image).
198 // If a handler keyword does not exist yet, it is created if
199 // <src>createHandler</src> is set.
200 // Otherwise the handler is empty and no groups can be created for it.
201 virtual ImageAttrHandler& attrHandler (Bool createHandler=False);
202
203 // Do the actual getting of an array of values.
204 virtual Bool doGetSlice (Array<T>& buffer, const Slicer& section);
205
206 // Putting data is not possible.
207 virtual void doPutSlice (const Array<T>& sourceBuffer,
208 const IPosition& where,
209 const IPosition& stride);
210
211 // Get a section of the mask.
212 virtual Bool doGetMaskSlice (Array<Bool>& buffer, const Slicer& section);
213
214 // This function is used by the LatticeIterator class to generate an
215 // iterator of the correct type for this Lattice. Not recommended
216 // for general use.
218 (const LatticeNavigator& navigator,
219 Bool useRef) const;
220
221 // Get the best cursor shape.
222 virtual IPosition doNiceCursorShape (uInt maxPixels) const;
223
224 // Handle the (un)locking and syncing, etc.
225 // <group>
226 virtual Bool lock (FileLocker::LockType, uInt nattempts);
227 virtual void unlock();
229 virtual void resync();
230 virtual void flush();
231 virtual void tempClose();
232 virtual void reopen();
233 // </group>
234
235private:
236 //# itsImagePtr points to the parent image.
239
240 //# Make members of parent class known.
241public:
242 using ImageInterface<T>::logger;
243protected:
245};
246
247
248
249} //# NAMESPACE CASACORE - END
250
251#ifndef CASACORE_NO_AUTO_TEMPLATES
252#include <casacore/images/Images/CurvedImage2D.tcc>
253#endif //# CASACORE_NO_AUTO_TEMPLATES
254#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? It does if its parent has 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? It is if its parent image is 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:93
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:223
this file contains all the compiler specific defines
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