00001 //# CurvedImage2D.h: An image crosscut based on a curve in a plane 00002 //# Copyright (C) 2003 00003 //# Associated Universities, Inc. Washington DC, USA. 00004 //# 00005 //# This library is free software; you can redistribute it and/or modify it 00006 //# under the terms of the GNU Library General Public License as published by 00007 //# the Free Software Foundation; either version 2 of the License, or (at your 00008 //# option) any later version. 00009 //# 00010 //# This library is distributed in the hope that it will be useful, but WITHOUT 00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00013 //# License for more details. 00014 //# 00015 //# You should have received a copy of the GNU Library General Public License 00016 //# along with this library; if not, write to the Free Software Foundation, 00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00018 //# 00019 //# Correspondence concerning AIPS++ should be addressed as follows: 00020 //# Internet email: aips2-request@nrao.edu. 00021 //# Postal address: AIPS++ Project Office 00022 //# National Radio Astronomy Observatory 00023 //# 520 Edgemont Road 00024 //# Charlottesville, VA 22903-2475 USA 00025 //# 00026 //# $Id$ 00027 00028 #ifndef IMAGES_CURVEDIMAGE2D_H 00029 #define IMAGES_CURVEDIMAGE2D_H 00030 00031 00032 //# Includes 00033 #include <images/Images/ImageInterface.h> 00034 00035 namespace casa { //# NAMESPACE CASA - BEGIN 00036 00037 //# Forward Declarations 00038 template <class T> class CurvedLattice2D; 00039 template <class T> class CLInterpolator2D; 00040 class PixelCurve1D; 00041 00042 00043 // <summary> 00044 // An image crosscut based on a curve in a plane. 00045 // </summary> 00046 // 00047 // <use visibility=export> 00048 // 00049 // <reviewed reviewer="" date="" tests="tCurvedImage2D.cc"> 00050 // </reviewed> 00051 // 00052 // <prerequisite> 00053 // <list> 00054 // <item> <linkto class=ImageInterface>ImageInterface</linkto> 00055 // <item> <linkto class=CurvedLattice2D>CurvedLattice2D</linkto> 00056 // </list> 00057 // </prerequisite> 00058 // 00059 // <synopsis> 00060 // Class CurvedImage2D can be used to make a crosscut through an image 00061 // with a dimensionality >= 2. The dimensionality of the resulting image 00062 // is one less. 00063 // The crosscut is based on a curve defined by a 00064 // <linkto class=PixelCurve1D>PixelCurve1D</linkto> object. The curve 00065 // can be any 1-dim function (e.g. straight line, spline) 00066 // supported by the Functionals module. The curve must be in one of the 00067 // main planes of the image as defined by the axes arguments in the 00068 // constructor. 00069 // <br>For example: in an RA-DEC-FREQ image a straight line can be 00070 // defined in the RA-DEC plane (axis1=0, axis2=1) from blc {0,0) to 00071 // trc (511,511). The crosscut will follow this line, so the result is 00072 // a 2-dim image with axes 'line' and FREQ. So it contains the spectrum 00073 // for all points on the line (points (0,0), (1,1) ... (511,511)). 00074 // <br>In this example the line only contains exact grid points. In 00075 // practice that usually won't be case, so interpolation has to be done. 00076 // This is done by a class derived from 00077 // <linkto class=CLInterpolator2D>CLInterpolator2D</linkto>, so any 00078 // interpolation scheme is possible. Currently only the nearest neighbour 00079 // scheme is implemented (<linkto class=CLIPNearest2D>CLIPNearest2D</linkto>). 00080 // </synopsis> 00081 // 00082 // <example> 00083 // The following example uses a 3-dim image. 00084 // It makes a crosscut using a line from the blc to the trc in the XY plane. 00085 // The number of points on the line is the maximum of the number of points 00086 // in X and Y. 00087 // <srcblock> 00088 // // Open an image. 00089 // PagedImage<Float> image("name.img"); 00090 // // Make a straight line from (0,0) to the trc. 00091 // IPosition shp = lat.shape(); 00092 // Int xtop = shp(0); 00093 // Int ytop = shp(1); 00094 // Int nr = xtop; 00095 // if (nr > ytop) nr = ytop; 00096 // PixelCurve1D pc(0, 0, xtop-1, ytop-1, nr); 00097 // // Create the crosscut image. 00098 // // The new axis (the curve axis) is the first axis in the result. 00099 // CurvedImage2D<Float> clat(image, CLIPNearest2D<Float>(), pc, 0, 1, 0); 00100 // </srcblock> 00101 // Note that in the general case the line (or any curve) won't be from 00102 // the blc to the trc. In fact, it is possible to give any starting and 00103 // end point and any number of points on the curve. 00104 // </example> 00105 // 00106 // <motivation> 00107 // Users like to view arbitrary image crosscuts. 00108 // </motivation> 00109 // 00110 //# <todo asof="1998/02/09"> 00111 //# </todo> 00112 00113 00114 template <class T> class CurvedImage2D: public ImageInterface<T> 00115 { 00116 public: 00117 // The default constructor 00118 CurvedImage2D(); 00119 00120 // Take a curved slice from the given image. 00121 // The <linkto class=PixelCurve1D>PixelCurve1D</linkto> object defines 00122 // the curve in one of the planes of the image. The arguments axis1 00123 // and axis2 define the plane the curve is in. 00124 // The <linkto class=CLInterpolator2D>CLInterpolator2D</linkto> object 00125 // defines the interpolation scheme for pixels that are not on grid points. 00126 // An example is CLIPNearest2D which takes the nearest neighbour. 00127 // The dimensionality of the CurvedImage2D is one less than the 00128 // dimensionality of the given image. Two axes (axis1 and axis2) are 00129 // replaced by the new axis representing the curve. The argument 00130 // curveAxis defines the axis number of the new axis. It defaults to the 00131 // last axis. 00132 // An exception is thrown if the dimensionality of the input image is < 2 00133 // or if the given axes numbers are too high. 00134 // Note that the output CoordinateSystem of the CurvedImage is just a dummy 00135 // LinearCoordinate at this point. The values are all arbitrary. 00136 CurvedImage2D (const ImageInterface<T>&, const CLInterpolator2D<T>&, 00137 const PixelCurve1D&, uInt axis1, uInt axis2, 00138 Int curveAxis=-1); 00139 00140 // Copy constructor (reference semantics). 00141 CurvedImage2D (const CurvedImage2D<T>& other); 00142 00143 virtual ~CurvedImage2D(); 00144 00145 // Assignment (reference semantics). 00146 CurvedImage2D<T>& operator= (const CurvedImage2D<T>& other); 00147 00148 // Make a copy of the object (reference semantics). 00149 // <group> 00150 virtual ImageInterface<T>* cloneII() const; 00151 // </group> 00152 00153 // Get the image type (returns name of derived class). 00154 virtual String imageType() const; 00155 00156 // Is the CurvedImage2D masked? 00157 // It is if its parent image is masked. 00158 virtual Bool isMasked() const; 00159 00160 // Does the image object have a pixelmask? 00161 // It does if its parent has a pixelmask. 00162 virtual Bool hasPixelMask() const; 00163 00164 // Get access to the pixelmask in use (thus to the pixelmask of the parent). 00165 // An exception is thrown if the parent does not have a pixelmask. 00166 // <group> 00167 virtual const Lattice<Bool>& pixelMask() const; 00168 virtual Lattice<Bool>& pixelMask(); 00169 // </group> 00170 00171 // Get the region used (always returns 0). 00172 virtual const LatticeRegion* getRegionPtr() const; 00173 00174 // A CurvedImage2D is not persistent. 00175 virtual Bool isPersistent() const; 00176 00177 // Is the CurvedImage2D paged to disk? 00178 virtual Bool isPaged() const; 00179 00180 // An CurvedImage2D is not writable 00181 virtual Bool isWritable() const; 00182 00183 // Returns the shape of the CurvedImage2D 00184 virtual IPosition shape() const; 00185 00186 // This function returns the recommended maximum number of pixels to 00187 // include in the cursor of an iterator. 00188 virtual uInt advisedMaxPixels() const; 00189 00190 // Function which changes the shape of the CurvedImage2D. 00191 // Throws an exception as resizing an CurvedImage2D is not possible. 00192 virtual void resize(const TiledShape& newShape); 00193 00194 // Return the name of the parent ImageInterface object. 00195 virtual String name (Bool stripPath=False) const; 00196 00197 // Check class invariants. 00198 virtual Bool ok() const; 00199 00200 // Do the actual getting of an array of values. 00201 virtual Bool doGetSlice (Array<T>& buffer, const Slicer& section); 00202 00203 // Putting data is not possible. 00204 virtual void doPutSlice (const Array<T>& sourceBuffer, 00205 const IPosition& where, 00206 const IPosition& stride); 00207 00208 // Get a section of the mask. 00209 virtual Bool doGetMaskSlice (Array<Bool>& buffer, const Slicer& section); 00210 00211 // This function is used by the LatticeIterator class to generate an 00212 // iterator of the correct type for this Lattice. Not recommended 00213 // for general use. 00214 virtual LatticeIterInterface<T>* makeIter 00215 (const LatticeNavigator& navigator, 00216 Bool useRef) const; 00217 00218 // Get the best cursor shape. 00219 virtual IPosition doNiceCursorShape (uInt maxPixels) const; 00220 00221 // Handle the (un)locking and syncing, etc.. 00222 // <group> 00223 virtual Bool lock (FileLocker::LockType, uInt nattempts); 00224 virtual void unlock(); 00225 virtual Bool hasLock (FileLocker::LockType) const; 00226 virtual void resync(); 00227 virtual void flush(); 00228 virtual void tempClose(); 00229 virtual void reopen(); 00230 // </group> 00231 00232 private: 00233 //# itsImagePtr points to the parent image. 00234 ImageInterface<T>* itsImagePtr; 00235 CurvedLattice2D<T>* itsCurLatPtr; 00236 00237 //# Make members of parent class known. 00238 public: 00239 using ImageInterface<T>::logger; 00240 protected: 00241 using ImageInterface<T>::setCoordsMember; 00242 }; 00243 00244 00245 00246 } //# NAMESPACE CASA - END 00247 00248 #ifndef AIPS_NO_TEMPLATE_SRC 00249 #include <images/Images/CurvedImage2D.cc> 00250 #endif //# AIPS_NO_TEMPLATE_SRC 00251 #endif
1.5.1