MomentClip.h

Go to the documentation of this file.
00001 //# MomentClip.h: base class for moment generator
00002 //# Copyright (C) 1996,1997,1998,1999,2000,2001,2002,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: MomentsBase.h 20299 2008-04-03 05:56:44Z gervandiepen $
00027 
00028 #ifndef IMAGEANALYSIS_MOMENTCLIP_H
00029 #define IMAGEANALYSIS_MOMENTCLIP_H
00030 
00031 #include <casacore/casa/Arrays/Vector.h>
00032 
00033 #include <imageanalysis/ImageAnalysis/MomentCalcBase.h>
00034 
00035 namespace casa {
00036 
00037 // <summary> Computes simple clipped, and masked moments</summary>
00038 // <use visibility=export>
00039 //
00040 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
00041 // </reviewed>
00042 //
00043 // <prerequisite>
00044 //   <li> <linkto class="MomentsBase">MomentsBase</linkto>
00045 //   <li> <linkto class="ImageMoments">ImageMoments</linkto>
00046 //   <li> <linkto class="MSMoments">MSMoments</linkto>
00047 //   <li> <linkto class="LatticeApply">LatticeApply</linkto>
00048 //   <li> <linkto class="MomentCalcBase">MomentCalcBase</linkto>
00049 //   <li> <linkto class="LineCollapser">LineCollapser</linkto>
00050 // </prerequisite>
00051 //
00052 // <synopsis>
00053 //  This concrete class is derived from the abstract base class MomentCalcBase
00054 //  which provides an interface layer to the ImageMoments or MSMoments driver class.
00055 //  ImageMoments or MSMoments creates a MomentClip object and passes it to the LatticeApply
00056 //  function, lineMultiApply. This function iterates through a given lattice,
00057 //  and invokes the <src>multiProcess</src> member function of MomentClip on each vector
00058 //  of pixels that it extracts from the input lattice.  The <src>multiProcess</src>
00059 //  function returns a vector of moments which are inserted into the output
00060 //  lattices also supplied to the LatticeApply function.
00061 //
00062 //  MomentClip computes moments directly from a vector of pixel intensities
00063 //  extracted from the primary lattice.  An optional pixel intensity inclusion
00064 //  or exclusion range can be applied.   It can also compute a mask based on the
00065 //  inclusion or exclusion ranges applied to an ancilliary lattice (the ancilliary
00066 //  vector corresponding to the primary vector is extracted).  This mask is then
00067 //  applied to the primary vector for moment computation (ImageMoments or MSMoments offers
00068 //  a smoothed version of the primary lattice as the ancilliary lattice)
00069 //
00070 //  The constructor takes an MomentsBase object that is actually an ImageMoments or
00071 //  an MSMoments object; the one that is constructing
00072 //  the MomentClip object of course.   There is much control information embodied
00073 //  in the state of the ImageMoments or MSMoments object.  This information is extracted by the
00074 //  MomentCalcBase class and passed on to MomentClip for consumption.
00075 //
00076 //  Note that the ancilliary lattice is only accessed if the ImageMoments or MSMoments
00077 //  object indicates that a pixel inclusion or exclusion range has been
00078 //  given as well as the pointer to the lattice having a non-zero value.
00079 //
00080 //  See the <linkto class="MomentsBase">MomentsBase</linkto>,
00081 //  <linkto class="ImageMoments">ImageMoments</linkto>, and
00082 //  <linkto class="MSMoments">MSMoments</linkto>
00083 //  for discussion about the moments that are available for computation.
00084 //
00085 // </synopsis>
00086 //
00087 // <example>
00088 // This example comes from ImageMoments.   outPt is a pointer block holding
00089 // pointers to the output lattices.  The ancilliary masking lattice is
00090 // just a smoothed version of the input lattice.
00091 //
00092 // <srcBlock>
00093 //
00096 //
00097 //   MomentCalcBase<T>* pMomentCalculator = 0;
00098 //   if (clipMethod || smoothClipMethod) {
00099 //      pMomentCalculator = new MomentClip<T>(pSmoothedImage, *this, os_p, outPt.nelements());
00100 //   } else if (windowMethod) {
00101 //      pMomentCalculator = new MomentWindow<T>(pSmoothedImage, *this, os_p, outPt.nelements());
00102 //   } else if (fitMethod) {
00103 //      pMomentCalculator = new MomentFit<T>(*this, os_p, outPt.nelements());
00104 //   }
00105 //
00107 //
00108 //   LatticeApply<T>::lineMultiApply(outPt, *pInImage_p, *pMomentCalculator,
00109 //                                   momentAxis_p, pProgressMeter);
00110 //   delete pMomentCalculator;
00111 //
00112 // </srcBlock>
00113 // </example>
00114 //
00115 // <note role=tip>
00116 // Note that there are is assignment operator or copy constructor.
00117 // Do not use the ones the system would generate either.
00118 // </note>
00119 //
00120 // <todo asof="yyyy/mm/dd">
00121 // </todo>
00122 
00123 template <class T> class MomentClip: public MomentCalcBase<T> {
00124 public:
00125 
00126     // Constructor.  The pointer is to an ancilliary  lattice used as a mask.
00127     // If no masking lattice is desired, the pointer value must be zero.  We also
00128     // need the ImageMoments or MSMoments object which is calling us, its
00129     // logger, and the number of output lattices it has created.
00130     MomentClip(shared_ptr<Lattice<T>> pAncilliaryLattice,
00131             MomentsBase<T>& iMom,
00132             LogIO& os,
00133             const uInt nLatticeOut);
00134 
00135     // Destructor (does nothing).
00136     virtual ~MomentClip();
00137 
00138     // This function is not implemented and throws an exception.
00139     virtual void process(
00140         T& out, Bool& outMask,
00141         const Vector<T>& in,
00142         const Vector<Bool>& inMask,
00143         const IPosition& pos
00144     );
00145 
00146     // This function returns a vector of numbers from each input vector.
00147     // the output vector contains the moments known to the ImageMoments
00148     // or MSMoments object passed into the constructor.
00149     virtual void multiProcess(
00150         Vector<T>& out, Vector<Bool>& outMask,
00151         const Vector<T>& in,
00152         const Vector<Bool>& inMask,
00153         const IPosition& pos
00154     );
00155 
00156     // Can handle null mask
00157     virtual Bool canHandleNullMask() const {return True;};
00158 
00159 private:
00160 
00161     shared_ptr<Lattice<T>> _ancilliaryLattice;
00162     MomentsBase<T>& iMom_p;
00163     LogIO os_p;
00164 
00165     const Vector<T>* pProfileSelect_p = nullptr;
00166     Vector<T> ancilliarySliceRef_p;
00167     Vector<T> selectedData_p;
00168     Vector<Int> selectedDataIndex_p;
00169     Bool doInclude_p, doExclude_p;
00170     Vector<T> range_p;
00171     IPosition sliceShape_p;
00172 
00173 protected:
00174     using MomentCalcBase<T>::constructorCheck;
00175     using MomentCalcBase<T>::setPosLabel;
00176     using MomentCalcBase<T>::selectMoments_p;
00177     using MomentCalcBase<T>::calcMoments_p;
00178     using MomentCalcBase<T>::calcMomentsMask_p;
00179     using MomentCalcBase<T>::doMedianI_p;
00180     using MomentCalcBase<T>::doMedianV_p;
00181     using MomentCalcBase<T>::doAbsDev_p;
00182     using MomentCalcBase<T>::cSys_p;
00183     using MomentCalcBase<T>::doCoordProfile_p;
00184     using MomentCalcBase<T>::doCoordRandom_p;
00185     using MomentCalcBase<T>::pixelIn_p;
00186     using MomentCalcBase<T>::worldOut_p;
00187     using MomentCalcBase<T>::sepWorldCoord_p;
00188     using MomentCalcBase<T>::integratedScaleFactor_p;
00189     using MomentCalcBase<T>::momAxisType_p;
00190     using MomentCalcBase<T>::nFailed_p;
00191     //using MomentCalcBase<T>::abcissa_p;
00192 };
00193 
00194 }
00195 
00196 #ifndef AIPS_NO_TEMPLATE_SRC
00197 #include <imageanalysis/ImageAnalysis/MomentClip.tcc>
00198 #endif
00199 
00200 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1