RebinImage.h

Go to the documentation of this file.
00001 //# RebinImage.h: rebin an image
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_REBINIMAGE_H
00029 #define IMAGES_REBINIMAGE_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 RebinLattice;
00040 class LogIO;
00041 
00042 // <summary>
00043 // Rebin an image
00044 // </summary>
00045 //
00046 // <use visibility=export>
00047 //
00048 // <reviewed reviewer="" date="" tests="tRebinImage.cc">
00049 // </reviewed>
00050 //
00051 // <prerequisite>
00052 //   <li> <linkto class=ImageInterface>ImageInterface</linkto>
00053 //   <li> <linkto class=RebinLattice>RebinLattice</linkto>
00054 // </prerequisite>
00055 //
00056 // <synopsis> 
00057 // Class RebinImage can be used to rebin (data averaged over bin) an image 
00058 // by integer amounts per axis.
00059 // </synopsis> 
00060 //
00061 // <example>
00062 // <srcblock>
00063 //    IPosition factors(2,2,2);
00064 //    PagedImage<Float> imageIn(String("myImage")):
00065 //    RebinLattice<Float> rb(imageIn, factors);
00066 //    IPosition shapeOut = rb.shape();
00067 //    TiledShape tShapeOut(shapeOut);
00068 //    TempImage<Float> imageOut(tShapeOut, rb.coordinates());
00069 //    LatticeUtilities::copyDataAndMask(os, imageOut, rb);
00070 //    ImageUtilities::copyMiscellaneous (imageOut, imageIn);
00071 // </srcblock>
00072 // </example>
00073 //
00074 // <motivation>
00075 // Users like to rebin images...
00076 // </motivation>
00077 //
00078 // <todo asof="2004/04/07">
00079 // </todo>
00080 
00081 
00082 template <class T> class RebinImage: public ImageInterface<T>
00083 {
00084 public: 
00085 
00086   // Default constructor (object useless)
00087   RebinImage ();
00088 
00089   // Constructor. The bin factors don't have to be integral. Anything left over
00090   // at the end is treated as a full bin.
00091   RebinImage (const ImageInterface<T>&, const IPosition& factors);
00092 
00093   // Copy constructor (reference semantics).
00094   RebinImage (const RebinImage<T>& other);
00095     
00096   virtual ~RebinImage();
00097 
00098   // Assignment (reference semantics).
00099   RebinImage<T>& operator= (const RebinImage<T>& other);
00100 
00101   // Make a copy of the object (reference semantics).
00102   // <group>
00103   virtual ImageInterface<T>* cloneII() const;
00104   // </group>
00105 
00106   // Get the image type (returns name of derived class).
00107   virtual String imageType() const;
00108 
00109   // Is the RebinImage masked?
00110   // It is if its parent image is masked.
00111   virtual Bool isMasked() const;
00112 
00113   // Does the image object have a pixelmask?
00114   // It does if its parent has a pixelmask.
00115   virtual Bool hasPixelMask() const;
00116 
00117   // Get access to the pixelmask in use (thus to the pixelmask of the parent).
00118   // An exception is thrown if the parent does not have a pixelmask.
00119   // <group>
00120   virtual const Lattice<Bool>& pixelMask() const;
00121   virtual Lattice<Bool>& pixelMask();
00122   // </group>
00123 
00124   // Get the region used (always returns 0).
00125   virtual const LatticeRegion* getRegionPtr() const;
00126 
00127   // A RebinImage is not persistent.
00128   virtual Bool isPersistent() const;
00129 
00130   // Is the RebinImage paged to disk?
00131   virtual Bool isPaged() const;
00132 
00133   // An RebinImage is not writable
00134   virtual Bool isWritable() const;
00135 
00136   // Returns the shape of the RebinImage
00137   virtual IPosition shape() const;
00138   
00139   // This function returns the recommended maximum number of pixels to
00140   // include in the cursor of an iterator.
00141   virtual uInt advisedMaxPixels() const;
00142 
00143   // Function which changes the shape of the RebinImage.
00144   // Throws an exception as resizing an RebinImage is not possible.
00145   virtual void resize(const TiledShape& newShape);
00146 
00147   // Return the name of the parent ImageInterface object. 
00148   virtual String name (Bool stripPath=False) const;
00149   
00150   // Check class invariants.
00151   virtual Bool ok() const;
00152 
00153   // Get access to the attribute handler (of the parent image).
00154   // If a handler keyword does not exist yet, it is created if
00155   // <src>createHandler</src> is set.
00156   // Otherwise the handler is empty and no groups can be created for it.
00157   virtual ImageAttrHandler& attrHandler (Bool createHandler=False);
00158 
00159   // Do the actual getting of an array of values.
00160   // Non-unit strides are not yet supported.
00161   virtual Bool doGetSlice (Array<T>& buffer, const Slicer& section);
00162 
00163   // Putting data is not possible as the lattice is not writable.
00164   virtual void doPutSlice (const Array<T>& sourceBuffer,
00165                            const IPosition& where,
00166                            const IPosition& stride);
00167   
00168   // Get a section of the mask.
00169   // Non-unit strides are not yet supported.
00170   virtual Bool doGetMaskSlice (Array<Bool>& buffer, const Slicer& section);
00171 
00172   // This function is used by the LatticeIterator class to generate an
00173   // iterator of the correct type for this Lattice. Not recommended
00174   // for general use. 
00175   virtual LatticeIterInterface<T>* makeIter
00176                             (const LatticeNavigator& navigator,
00177                              Bool useRef) const;
00178 
00179   // Get the best cursor shape.
00180   virtual IPosition doNiceCursorShape (uInt maxPixels) const;
00181 
00182   // Handle the (un)locking and syncing, etc.
00183   // <group>
00184   virtual Bool lock (FileLocker::LockType, uInt nattempts);
00185   virtual void unlock();
00186   virtual Bool hasLock (FileLocker::LockType) const;
00187   virtual void resync();
00188   virtual void flush();
00189   virtual void tempClose();
00190   virtual void reopen();
00191   // </group>
00192 
00193 private:
00194   //# itsImagePtr points to the parent image.
00195   ImageInterface<T>* itsImagePtr;
00196   RebinLattice<T>*   itsRebinPtr;
00197 
00198   //# Make members of parent class known.
00199 public:
00200   using ImageInterface<T>::logger;
00201 protected:
00202   using ImageInterface<T>::setCoordsMember;
00203 };
00204 
00205 
00206 
00207 } //# NAMESPACE CASACORE - END
00208 
00209 #ifndef CASACORE_NO_AUTO_TEMPLATES
00210 #include <casacore/images/Images/RebinImage.tcc>
00211 #endif //# CASACORE_NO_AUTO_TEMPLATES
00212 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1