CurvedImage2D.h

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

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1