casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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: aips2-request@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 //# $Id$
27 
28 #ifndef IMAGES_CURVEDIMAGE2D_H
29 #define IMAGES_CURVEDIMAGE2D_H
30 
31 
32 //# Includes
33 #include <casacore/casa/aips.h>
35 
36 namespace casacore { //# NAMESPACE CASACORE - BEGIN
37 
38 //# Forward Declarations
39 template <class T> class CurvedLattice2D;
40 template <class T> class CLInterpolator2D;
41 class PixelCurve1D;
42 
43 
44 // <summary>
45 // An image crosscut based on a curve in a plane.
46 // </summary>
47 //
48 // <use visibility=export>
49 //
50 // <reviewed reviewer="" date="" tests="tCurvedImage2D.cc">
51 // </reviewed>
52 //
53 // <prerequisite>
54 // <li> <linkto class=ImageInterface>ImageInterface</linkto>
55 // <li> <linkto class=CurvedLattice2D>CurvedLattice2D</linkto>
56 // </prerequisite>
57 //
58 // <synopsis>
59 // Class CurvedImage2D can be used to make a crosscut through an image
60 // with a dimensionality >= 2. The dimensionality of the resulting image
61 // is one less.
62 // The crosscut is based on a curve defined by a
63 // <linkto class=PixelCurve1D>PixelCurve1D</linkto> object. The curve
64 // can be any 1-dim function (e.g. straight line, spline)
65 // supported by the Functionals module. The curve must be in one of the
66 // main planes of the image as defined by the axes arguments in the
67 // constructor.
68 // <br>For example: in an RA-DEC-FREQ image a straight line can be
69 // defined in the RA-DEC plane (axis1=0, axis2=1) from blc {0,0) to
70 // trc (511,511). The crosscut will follow this line, so the result is
71 // a 2-dim image with axes 'line' and FREQ. So it contains the spectrum
72 // for all points on the line (points (0,0), (1,1) ... (511,511)).
73 // <br>In this example the line only contains exact grid points. In
74 // practice that usually won't be case, so interpolation has to be done.
75 // This is done by a class derived from
76 // <linkto class=CLInterpolator2D>CLInterpolator2D</linkto>, so any
77 // interpolation scheme is possible. Currently only the nearest neighbour
78 // scheme is implemented (<linkto class=CLIPNearest2D>CLIPNearest2D</linkto>).
79 // </synopsis>
80 //
81 // <example>
82 // The following example uses a 3-dim image.
83 // It makes a crosscut using a line from the blc to the trc in the XY plane.
84 // The number of points on the line is the maximum of the number of points
85 // in X and Y.
86 // <srcblock>
87 // // Open an image.
88 // PagedImage<Float> image("name.img");
89 // // Make a straight line from (0,0) to the trc.
90 // IPosition shp = lat.shape();
91 // Int xtop = shp(0);
92 // Int ytop = shp(1);
93 // Int nr = xtop;
94 // if (nr > ytop) nr = ytop;
95 // PixelCurve1D pc(0, 0, xtop-1, ytop-1, nr);
96 // // Create the crosscut image.
97 // // The new axis (the curve axis) is the first axis in the result.
98 // CurvedImage2D<Float> clat(image, CLIPNearest2D<Float>(), pc, 0, 1, 0);
99 // </srcblock>
100 // Note that in the general case the line (or any curve) won't be from
101 // the blc to the trc. In fact, it is possible to give any starting and
102 // end point and any number of points on the curve.
103 // </example>
104 //
105 // <motivation>
106 // Users like to view arbitrary image crosscuts.
107 // </motivation>
108 //
109 //# <todo asof="1998/02/09">
110 //# </todo>
111 
112 
113 template <class T> class CurvedImage2D: public ImageInterface<T>
114 {
115 public:
116  // The default constructor
117  CurvedImage2D();
118 
119  // Take a curved slice from the given image.
120  // The <linkto class=PixelCurve1D>PixelCurve1D</linkto> object defines
121  // the curve in one of the planes of the image. The arguments axis1
122  // and axis2 define the plane the curve is in.
123  // The <linkto class=CLInterpolator2D>CLInterpolator2D</linkto> object
124  // defines the interpolation scheme for pixels that are not on grid points.
125  // An example is CLIPNearest2D which takes the nearest neighbour.
126  // The dimensionality of the CurvedImage2D is one less than the
127  // dimensionality of the given image. Two axes (axis1 and axis2) are
128  // replaced by the new axis representing the curve. The argument
129  // curveAxis defines the axis number of the new axis. It defaults to the
130  // last axis.
131  // An exception is thrown if the dimensionality of the input image is < 2
132  // or if the given axes numbers are too high.
133  // Note that the output CoordinateSystem of the CurvedImage is just a dummy
134  // LinearCoordinate at this point. The values are all arbitrary.
136  const PixelCurve1D&, uInt axis1, uInt axis2,
137  Int curveAxis=-1);
138 
139  // Copy constructor (reference semantics).
140  CurvedImage2D (const CurvedImage2D<T>& other);
141 
142  virtual ~CurvedImage2D();
143 
144  // Assignment (reference semantics).
146 
147  // Make a copy of the object (reference semantics).
148  // <group>
149  virtual ImageInterface<T>* cloneII() const;
150  // </group>
151 
152  // Get the image type (returns name of derived class).
153  virtual String imageType() const;
154 
155  // Is the CurvedImage2D masked?
156  // It is if its parent image is masked.
157  virtual Bool isMasked() const;
158 
159  // Does the image object have a pixelmask?
160  // It does if its parent has a pixelmask.
161  virtual Bool hasPixelMask() const;
162 
163  // Get access to the pixelmask in use (thus to the pixelmask of the parent).
164  // An exception is thrown if the parent does not have a pixelmask.
165  // <group>
166  virtual const Lattice<Bool>& pixelMask() const;
167  virtual Lattice<Bool>& pixelMask();
168  // </group>
169 
170  // Get the region used (always returns 0).
171  virtual const LatticeRegion* getRegionPtr() const;
172 
173  // A CurvedImage2D is not persistent.
174  virtual Bool isPersistent() const;
175 
176  // Is the CurvedImage2D paged to disk?
177  virtual Bool isPaged() const;
178 
179  // An CurvedImage2D is not writable
180  virtual Bool isWritable() const;
181 
182  // Returns the shape of the CurvedImage2D
183  virtual IPosition shape() const;
184 
185  // This function returns the recommended maximum number of pixels to
186  // include in the cursor of an iterator.
187  virtual uInt advisedMaxPixels() const;
188 
189  // Function which changes the shape of the CurvedImage2D.
190  // Throws an exception as resizing an CurvedImage2D is not possible.
191  virtual void resize(const TiledShape& newShape);
192 
193  // Return the name of the parent ImageInterface object.
194  virtual String name (Bool stripPath=False) const;
195 
196  // Check class invariants.
197  virtual Bool ok() const;
198 
199  // Get access to the attribute handler (of the parent image).
200  // If a handler keyword does not exist yet, it is created if
201  // <src>createHandler</src> is set.
202  // Otherwise the handler is empty and no groups can be created for it.
203  virtual ImageAttrHandler& attrHandler (Bool createHandler=False);
204 
205  // Do the actual getting of an array of values.
206  virtual Bool doGetSlice (Array<T>& buffer, const Slicer& section);
207 
208  // Putting data is not possible.
209  virtual void doPutSlice (const Array<T>& sourceBuffer,
210  const IPosition& where,
211  const IPosition& stride);
212 
213  // Get a section of the mask.
214  virtual Bool doGetMaskSlice (Array<Bool>& buffer, const Slicer& section);
215 
216  // This function is used by the LatticeIterator class to generate an
217  // iterator of the correct type for this Lattice. Not recommended
218  // for general use.
220  (const LatticeNavigator& navigator,
221  Bool useRef) const;
222 
223  // Get the best cursor shape.
224  virtual IPosition doNiceCursorShape (uInt maxPixels) const;
225 
226  // Handle the (un)locking and syncing, etc.
227  // <group>
228  virtual Bool lock (FileLocker::LockType, uInt nattempts);
229  virtual void unlock();
230  virtual Bool hasLock (FileLocker::LockType) const;
231  virtual void resync();
232  virtual void flush();
233  virtual void tempClose();
234  virtual void reopen();
235  // </group>
236 
237 private:
238  //# itsImagePtr points to the parent image.
241 
242  //# Make members of parent class known.
243 public:
245 protected:
247 };
248 
249 
250 
251 } //# NAMESPACE CASACORE - END
252 
253 #ifndef CASACORE_NO_AUTO_TEMPLATES
254 #include <casacore/images/Images/CurvedImage2D.tcc>
255 #endif //# CASACORE_NO_AUTO_TEMPLATES
256 #endif
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
ImageInterface< T > * itsImagePtr
int Int
Definition: aipstype.h:50
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 IPosition shape() const
Returns the shape of the CurvedImage2D.
virtual void flush()
Flush the data (but do not unlock).
virtual ImageAttrHandler & attrHandler(Bool createHandler=False)
Get access to the attribute handler (of the parent image).
CurvedLattice2D< T > * itsCurLatPtr
virtual Bool lock(FileLocker::LockType, uInt nattempts)
Handle the (un)locking and syncing, etc.
Abstract base class for interpolator used by CurvedLattice2D.
CurvedImage2D()
The default constructor.
virtual Bool doGetSlice(Array< T > &buffer, const Slicer &section)
Do the actual getting of an array of values.
virtual String name(Bool stripPath=False) const
Return the name of the parent ImageInterface object.
CurvedImage2D< T > & operator=(const CurvedImage2D< T > &other)
Assignment (reference semantics).
Abstract base class for an image attributes handler.
virtual Bool isPaged() const
Is the CurvedImage2D paged to disk?
virtual Bool ok() const
Check class invariants.
virtual void unlock()
virtual void resync()
Resynchronize the Lattice object with the lattice file.
A base class for Lattice iterators.
Definition: SubImage.h:46
Define the shape and tile shape.
Definition: TiledShape.h:99
virtual Bool isPersistent() const
A CurvedImage2D is not persistent.
A base class for astronomical images.
virtual void reopen()
Explicitly reopen the temporarily closed lattice.
virtual const Lattice< Bool > & pixelMask() const
Get access to the pixelmask in use (thus to the pixelmask of the parent).
virtual Bool isWritable() const
An CurvedImage2D is not writable.
Arbitrary 1-dim curve in a lattice plane.
Definition: PixelCurve1D.h:96
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
const Bool False
Definition: aipstype.h:44
template &lt;class T, class U&gt; class vector;
Definition: MSFlagger.h:37
A lattice crosscut based on a curve in a plane.
Specify which elements to extract from an n-dimensional array.
Definition: Slicer.h:289
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 void tempClose()
Temporarily close the lattice.
virtual Bool doGetMaskSlice(Array< Bool > &buffer, const Slicer &section)
Get a section of the mask.
An image crosscut based on a curve in a plane.
virtual uInt advisedMaxPixels() const
This function returns the recommended maximum number of pixels to include in the cursor of an iterato...
String: the storage and methods of handling collections of characters.
Definition: String.h:223
An optionally strided region in a Lattice.
Definition: LatticeRegion.h:74
virtual void doPutSlice(const Array< T > &sourceBuffer, const IPosition &where, const IPosition &stride)
Putting data is not possible.
virtual void resize(const TiledShape &newShape)
Function which changes the shape of the CurvedImage2D.
LockType
Define the possible lock types.
Definition: FileLocker.h:95
virtual IPosition doNiceCursorShape(uInt maxPixels) const
Get the best cursor shape.
virtual Bool hasLock(FileLocker::LockType) const
virtual ImageInterface< T > * cloneII() const
Make a copy of the object (reference semantics).
unsigned int uInt
Definition: aipstype.h:51
Abstract base class to steer lattice iterators.
virtual Bool isMasked() const
Is the CurvedImage2D masked? It is if its parent image is masked.
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42