LCOV - code coverage report
Current view: top level - imageanalysis/ImageAnalysis - MomentClip.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 0 1 0.0 %
Date: 2024-10-10 11:40:37 Functions: 0 1 0.0 %

          Line data    Source code
       1             : //# MomentClip.h: base class for moment generator
       2             : //# Copyright (C) 1996,1997,1998,1999,2000,2001,2002,2003
       3             : //# Associated Universities, Inc. Washington DC, USA.
       4             : //#
       5             : //# This library is free software; you can redistribute it and/or modify it
       6             : //# under the terms of the GNU Library General Public License as published by
       7             : //# the Free Software Foundation; either version 2 of the License, or (at your
       8             : //# option) any later version.
       9             : //#
      10             : //# This library is distributed in the hope that it will be useful, but WITHOUT
      11             : //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
      12             : //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
      13             : //# License for more details.
      14             : //#
      15             : //# You should have received a copy of the GNU Library General Public License
      16             : //# along with this library; if not, write to the Free Software Foundation,
      17             : //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
      18             : //#
      19             : //# Correspondence concerning AIPS++ should be addressed as follows:
      20             : //#        Internet email: casa-feedback@nrao.edu.
      21             : //#        Postal address: AIPS++ Project Office
      22             : //#                        National Radio Astronomy Observatory
      23             : //#                        520 Edgemont Road
      24             : //#                        Charlottesville, VA 22903-2475 USA
      25             : //#
      26             : //# $Id: MomentsBase.h 20299 2008-04-03 05:56:44Z gervandiepen $
      27             : 
      28             : #ifndef IMAGEANALYSIS_MOMENTCLIP_H
      29             : #define IMAGEANALYSIS_MOMENTCLIP_H
      30             : 
      31             : #include <casacore/casa/Arrays/Vector.h>
      32             : 
      33             : #include <imageanalysis/ImageAnalysis/MomentCalcBase.h>
      34             : 
      35             : namespace casa {
      36             : 
      37             : // <summary> Computes simple clipped, and masked moments</summary>
      38             : // <use visibility=export>
      39             : //
      40             : // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
      41             : // </reviewed>
      42             : //
      43             : // <prerequisite>
      44             : //   <li> <linkto class="MomentsBase">MomentsBase</linkto>
      45             : //   <li> <linkto class="ImageMoments">ImageMoments</linkto>
      46             : //   <li> <linkto class="MSMoments">MSMoments</linkto>
      47             : //   <li> <linkto class="casacore::LatticeApply">casacore::LatticeApply</linkto>
      48             : //   <li> <linkto class="MomentCalcBase">MomentCalcBase</linkto>
      49             : //   <li> <linkto class="casacore::LineCollapser">casacore::LineCollapser</linkto>
      50             : // </prerequisite>
      51             : //
      52             : // <synopsis>
      53             : //  This concrete class is derived from the abstract base class MomentCalcBase
      54             : //  which provides an interface layer to the ImageMoments or MSMoments driver class.
      55             : //  ImageMoments or MSMoments creates a MomentClip object and passes it to the LatticeApply
      56             : //  function, lineMultiApply. This function iterates through a given lattice,
      57             : //  and invokes the <src>multiProcess</src> member function of MomentClip on each vector
      58             : //  of pixels that it extracts from the input lattice.  The <src>multiProcess</src>
      59             : //  function returns a vector of moments which are inserted into the output
      60             : //  lattices also supplied to the casacore::LatticeApply function.
      61             : //
      62             : //  MomentClip computes moments directly from a vector of pixel intensities
      63             : //  extracted from the primary lattice.  An optional pixel intensity inclusion
      64             : //  or exclusion range can be applied.   It can also compute a mask based on the
      65             : //  inclusion or exclusion ranges applied to an ancilliary lattice (the ancilliary
      66             : //  vector corresponding to the primary vector is extracted).  This mask is then
      67             : //  applied to the primary vector for moment computation (ImageMoments or MSMoments offers
      68             : //  a smoothed version of the primary lattice as the ancilliary lattice)
      69             : //
      70             : //  The constructor takes an MomentsBase object that is actually an ImageMoments or
      71             : //  an MSMoments object; the one that is constructing
      72             : //  the MomentClip object of course.   There is much control information embodied
      73             : //  in the state of the ImageMoments or MSMoments object.  This information is extracted by the
      74             : //  MomentCalcBase class and passed on to MomentClip for consumption.
      75             : //
      76             : //  Note that the ancilliary lattice is only accessed if the ImageMoments or MSMoments
      77             : //  object indicates that a pixel inclusion or exclusion range has been
      78             : //  given as well as the pointer to the lattice having a non-zero value.
      79             : //
      80             : //  See the <linkto class="MomentsBase">MomentsBase</linkto>,
      81             : //  <linkto class="ImageMoments">ImageMoments</linkto>, and
      82             : //  <linkto class="MSMoments">MSMoments</linkto>
      83             : //  for discussion about the moments that are available for computation.
      84             : //
      85             : // </synopsis>
      86             : //
      87             : // <example>
      88             : // This example comes from ImageMoments.   outPt is a pointer block holding
      89             : // pointers to the output lattices.  The ancilliary masking lattice is
      90             : // just a smoothed version of the input lattice.
      91             : //
      92             : // <srcBlock>
      93             : //
      94             : //// Construct desired moment calculator object.  Use it polymorphically
      95             : //// via a pointer to the base class.  os_P is a casacore::LogIO object.
      96             : //
      97             : //   MomentCalcBase<T>* pMomentCalculator = 0;
      98             : //   if (clipMethod || smoothClipMethod) {
      99             : //      pMomentCalculator = new MomentClip<T>(pSmoothedImage, *this, os_p, outPt.nelements());
     100             : //   } else if (windowMethod) {
     101             : //      pMomentCalculator = new MomentWindow<T>(pSmoothedImage, *this, os_p, outPt.nelements());
     102             : //   } else if (fitMethod) {
     103             : //      pMomentCalculator = new MomentFit<T>(*this, os_p, outPt.nelements());
     104             : //   }
     105             : //
     106             : //// Iterate optimally through the image, compute the moments, fill the output lattices
     107             : //
     108             : //   casacore::LatticeApply<T>::lineMultiApply(outPt, *pInImage_p, *pMomentCalculator,
     109             : //                                   momentAxis_p, pProgressMeter);
     110             : //   delete pMomentCalculator;
     111             : //
     112             : // </srcBlock>
     113             : // </example>
     114             : //
     115             : // <note role=tip>
     116             : // Note that there are is assignment operator or copy constructor.
     117             : // Do not use the ones the system would generate either.
     118             : // </note>
     119             : //
     120             : // <todo asof="yyyy/mm/dd">
     121             : // </todo>
     122             : 
     123             : template <class T> class MomentClip: public MomentCalcBase<T> {
     124             : public:
     125             : 
     126             :     // Constructor.  The pointer is to an ancilliary  lattice used as a mask.
     127             :     // If no masking lattice is desired, the pointer value must be zero.  We also
     128             :     // need the ImageMoments or MSMoments object which is calling us, its
     129             :     // logger, and the number of output lattices it has created.
     130             :     MomentClip(shared_ptr<casacore::Lattice<T>> pAncilliaryLattice,
     131             :             MomentsBase<T>& iMom,
     132             :             casacore::LogIO& os,
     133             :             const casacore::uInt nLatticeOut);
     134             : 
     135             :     // Destructor (does nothing).
     136             :     virtual ~MomentClip();
     137             : 
     138             :     // This function is not implemented and throws an exception.
     139             :     virtual void process(
     140             :         T& out, casacore::Bool& outMask,
     141             :         const casacore::Vector<T>& in,
     142             :         const casacore::Vector<casacore::Bool>& inMask,
     143             :         const casacore::IPosition& pos
     144             :     );
     145             : 
     146             :     // This function returns a vector of numbers from each input vector.
     147             :     // the output vector contains the moments known to the ImageMoments
     148             :     // or MSMoments object passed into the constructor.
     149             :     virtual void multiProcess(
     150             :         casacore::Vector<T>& out, casacore::Vector<casacore::Bool>& outMask,
     151             :         const casacore::Vector<T>& in,
     152             :         const casacore::Vector<casacore::Bool>& inMask,
     153             :         const casacore::IPosition& pos
     154             :     );
     155             : 
     156             :     // Can handle null mask
     157           0 :     virtual casacore::Bool canHandleNullMask() const {return true;};
     158             : 
     159             : private:
     160             : 
     161             :     shared_ptr<casacore::Lattice<T>> _ancilliaryLattice;
     162             :     MomentsBase<T>& iMom_p;
     163             :     casacore::LogIO os_p;
     164             : 
     165             :     const casacore::Vector<T>* pProfileSelect_p = nullptr;
     166             :     casacore::Vector<T> ancilliarySliceRef_p;
     167             :     casacore::Vector<T> selectedData_p;
     168             :     casacore::Vector<casacore::Int> selectedDataIndex_p;
     169             :     casacore::Bool doInclude_p, doExclude_p;
     170             :     casacore::Vector<T> range_p;
     171             :     casacore::IPosition sliceShape_p;
     172             : 
     173             : protected:
     174             :     using MomentCalcBase<T>::constructorCheck;
     175             :     using MomentCalcBase<T>::setPosLabel;
     176             :     using MomentCalcBase<T>::selectMoments_p;
     177             :     using MomentCalcBase<T>::calcMoments_p;
     178             :     using MomentCalcBase<T>::calcMomentsMask_p;
     179             :     using MomentCalcBase<T>::doMedianI_p;
     180             :     using MomentCalcBase<T>::doMedianV_p;
     181             :     using MomentCalcBase<T>::doAbsDev_p;
     182             :     using MomentCalcBase<T>::cSys_p;
     183             :     using MomentCalcBase<T>::doCoordProfile_p;
     184             :     using MomentCalcBase<T>::doCoordRandom_p;
     185             :     using MomentCalcBase<T>::pixelIn_p;
     186             :     using MomentCalcBase<T>::worldOut_p;
     187             :     using MomentCalcBase<T>::sepWorldCoord_p;
     188             :     using MomentCalcBase<T>::integratedScaleFactor_p;
     189             :     using MomentCalcBase<T>::momAxisType_p;
     190             :     using MomentCalcBase<T>::nFailed_p;
     191             :     //using MomentCalcBase<T>::abcissa_p;
     192             : };
     193             : 
     194             : }
     195             : 
     196             : #ifndef AIPS_NO_TEMPLATE_SRC
     197             : #include <imageanalysis/ImageAnalysis/MomentClip.tcc>
     198             : #endif
     199             : 
     200             : #endif

Generated by: LCOV version 1.16