casa
$Rev:20696$
|
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: CurvedImage2D.h 20505 2009-01-19 14:37:24Z gervandiepen $ 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 // <li> <linkto class=ImageInterface>ImageInterface</linkto> 00054 // <li> <linkto class=CurvedLattice2D>CurvedLattice2D</linkto> 00055 // </prerequisite> 00056 // 00057 // <synopsis> 00058 // Class CurvedImage2D can be used to make a crosscut through an image 00059 // with a dimensionality >= 2. The dimensionality of the resulting image 00060 // is one less. 00061 // The crosscut is based on a curve defined by a 00062 // <linkto class=PixelCurve1D>PixelCurve1D</linkto> object. The curve 00063 // can be any 1-dim function (e.g. straight line, spline) 00064 // supported by the Functionals module. The curve must be in one of the 00065 // main planes of the image as defined by the axes arguments in the 00066 // constructor. 00067 // <br>For example: in an RA-DEC-FREQ image a straight line can be 00068 // defined in the RA-DEC plane (axis1=0, axis2=1) from blc {0,0) to 00069 // trc (511,511). The crosscut will follow this line, so the result is 00070 // a 2-dim image with axes 'line' and FREQ. So it contains the spectrum 00071 // for all points on the line (points (0,0), (1,1) ... (511,511)). 00072 // <br>In this example the line only contains exact grid points. In 00073 // practice that usually won't be case, so interpolation has to be done. 00074 // This is done by a class derived from 00075 // <linkto class=CLInterpolator2D>CLInterpolator2D</linkto>, so any 00076 // interpolation scheme is possible. Currently only the nearest neighbour 00077 // scheme is implemented (<linkto class=CLIPNearest2D>CLIPNearest2D</linkto>). 00078 // </synopsis> 00079 // 00080 // <example> 00081 // The following example uses a 3-dim image. 00082 // It makes a crosscut using a line from the blc to the trc in the XY plane. 00083 // The number of points on the line is the maximum of the number of points 00084 // in X and Y. 00085 // <srcblock> 00086 // // Open an image. 00087 // PagedImage<Float> image("name.img"); 00088 // // Make a straight line from (0,0) to the trc. 00089 // IPosition shp = lat.shape(); 00090 // Int xtop = shp(0); 00091 // Int ytop = shp(1); 00092 // Int nr = xtop; 00093 // if (nr > ytop) nr = ytop; 00094 // PixelCurve1D pc(0, 0, xtop-1, ytop-1, nr); 00095 // // Create the crosscut image. 00096 // // The new axis (the curve axis) is the first axis in the result. 00097 // CurvedImage2D<Float> clat(image, CLIPNearest2D<Float>(), pc, 0, 1, 0); 00098 // </srcblock> 00099 // Note that in the general case the line (or any curve) won't be from 00100 // the blc to the trc. In fact, it is possible to give any starting and 00101 // end point and any number of points on the curve. 00102 // </example> 00103 // 00104 // <motivation> 00105 // Users like to view arbitrary image crosscuts. 00106 // </motivation> 00107 // 00108 //# <todo asof="1998/02/09"> 00109 //# </todo> 00110 00111 00112 template <class T> class CurvedImage2D: public ImageInterface<T> 00113 { 00114 public: 00115 // The default constructor 00116 CurvedImage2D(); 00117 00118 // Take a curved slice from the given image. 00119 // The <linkto class=PixelCurve1D>PixelCurve1D</linkto> object defines 00120 // the curve in one of the planes of the image. The arguments axis1 00121 // and axis2 define the plane the curve is in. 00122 // The <linkto class=CLInterpolator2D>CLInterpolator2D</linkto> object 00123 // defines the interpolation scheme for pixels that are not on grid points. 00124 // An example is CLIPNearest2D which takes the nearest neighbour. 00125 // The dimensionality of the CurvedImage2D is one less than the 00126 // dimensionality of the given image. Two axes (axis1 and axis2) are 00127 // replaced by the new axis representing the curve. The argument 00128 // curveAxis defines the axis number of the new axis. It defaults to the 00129 // last axis. 00130 // An exception is thrown if the dimensionality of the input image is < 2 00131 // or if the given axes numbers are too high. 00132 // Note that the output CoordinateSystem of the CurvedImage is just a dummy 00133 // LinearCoordinate at this point. The values are all arbitrary. 00134 CurvedImage2D (const ImageInterface<T>&, const CLInterpolator2D<T>&, 00135 const PixelCurve1D&, uInt axis1, uInt axis2, 00136 Int curveAxis=-1); 00137 00138 // Copy constructor (reference semantics). 00139 CurvedImage2D (const CurvedImage2D<T>& other); 00140 00141 virtual ~CurvedImage2D(); 00142 00143 // Assignment (reference semantics). 00144 CurvedImage2D<T>& operator= (const CurvedImage2D<T>& other); 00145 00146 // Make a copy of the object (reference semantics). 00147 // <group> 00148 virtual ImageInterface<T>* cloneII() const; 00149 // </group> 00150 00151 // Get the image type (returns name of derived class). 00152 virtual String imageType() const; 00153 00154 // Is the CurvedImage2D masked? 00155 // It is if its parent image is masked. 00156 virtual Bool isMasked() const; 00157 00158 // Does the image object have a pixelmask? 00159 // It does if its parent has a pixelmask. 00160 virtual Bool hasPixelMask() const; 00161 00162 // Get access to the pixelmask in use (thus to the pixelmask of the parent). 00163 // An exception is thrown if the parent does not have a pixelmask. 00164 // <group> 00165 virtual const Lattice<Bool>& pixelMask() const; 00166 virtual Lattice<Bool>& pixelMask(); 00167 // </group> 00168 00169 // Get the region used (always returns 0). 00170 virtual const LatticeRegion* getRegionPtr() const; 00171 00172 // A CurvedImage2D is not persistent. 00173 virtual Bool isPersistent() const; 00174 00175 // Is the CurvedImage2D paged to disk? 00176 virtual Bool isPaged() const; 00177 00178 // An CurvedImage2D is not writable 00179 virtual Bool isWritable() const; 00180 00181 // Returns the shape of the CurvedImage2D 00182 virtual IPosition shape() const; 00183 00184 // This function returns the recommended maximum number of pixels to 00185 // include in the cursor of an iterator. 00186 virtual uInt advisedMaxPixels() const; 00187 00188 // Function which changes the shape of the CurvedImage2D. 00189 // Throws an exception as resizing an CurvedImage2D is not possible. 00190 virtual void resize(const TiledShape& newShape); 00191 00192 // Return the name of the parent ImageInterface object. 00193 virtual String name (Bool stripPath=False) const; 00194 00195 // Check class invariants. 00196 virtual Bool ok() const; 00197 00198 // Do the actual getting of an array of values. 00199 virtual Bool doGetSlice (Array<T>& buffer, const Slicer& section); 00200 00201 // Putting data is not possible. 00202 virtual void doPutSlice (const Array<T>& sourceBuffer, 00203 const IPosition& where, 00204 const IPosition& stride); 00205 00206 // Get a section of the mask. 00207 virtual Bool doGetMaskSlice (Array<Bool>& buffer, const Slicer& section); 00208 00209 // This function is used by the LatticeIterator class to generate an 00210 // iterator of the correct type for this Lattice. Not recommended 00211 // for general use. 00212 virtual LatticeIterInterface<T>* makeIter 00213 (const LatticeNavigator& navigator, 00214 Bool useRef) const; 00215 00216 // Get the best cursor shape. 00217 virtual IPosition doNiceCursorShape (uInt maxPixels) const; 00218 00219 // Handle the (un)locking and syncing, etc. 00220 // <group> 00221 virtual Bool lock (FileLocker::LockType, uInt nattempts); 00222 virtual void unlock(); 00223 virtual Bool hasLock (FileLocker::LockType) const; 00224 virtual void resync(); 00225 virtual void flush(); 00226 virtual void tempClose(); 00227 virtual void reopen(); 00228 // </group> 00229 00230 private: 00231 //# itsImagePtr points to the parent image. 00232 ImageInterface<T>* itsImagePtr; 00233 CurvedLattice2D<T>* itsCurLatPtr; 00234 00235 //# Make members of parent class known. 00236 public: 00237 using ImageInterface<T>::logger; 00238 protected: 00239 using ImageInterface<T>::setCoordsMember; 00240 }; 00241 00242 00243 00244 } //# NAMESPACE CASA - END 00245 00246 #ifndef CASACORE_NO_AUTO_TEMPLATES 00247 #include <images/Images/CurvedImage2D.tcc> 00248 #endif //# CASACORE_NO_AUTO_TEMPLATES 00249 #endif