casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MomentClip.h
Go to the documentation of this file.
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: aips2-request@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 
32 
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 //
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 //
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(
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  virtual casacore::Bool canHandleNullMask() const {return true;};
158 
159 private:
160 
161  shared_ptr<casacore::Lattice<T>> _ancilliaryLattice;
164 
172 
173 protected:
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
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
A 1-D Specialization of the Array class.
This class is a base class for generating moments from an image or a spectral data.
casacore::Vector< T > selectedData_p
Definition: MomentClip.h:167
casacore::Vector< T > ancilliarySliceRef_p
Definition: MomentClip.h:166
virtual void process(T &out, casacore::Bool &outMask, const casacore::Vector< T > &in, const casacore::Vector< casacore::Bool > &inMask, const casacore::IPosition &pos)
This function is not implemented and throws an exception.
shared_ptr< casacore::Lattice< T > > _ancilliaryLattice
Definition: MomentClip.h:157
casacore::LogIO os_p
Definition: MomentClip.h:163
Abstract base class for moment calculator classes.
ostream-like interface to creating log messages.
Definition: LogIO.h:167
casacore::Vector< T > range_p
Definition: MomentClip.h:170
casacore::Vector< casacore::Int > selectedDataIndex_p
Definition: MomentClip.h:168
A templated, abstract base class for array-like objects.
casacore::Bool doInclude_p
Definition: MomentClip.h:169
casacore::IPosition sliceShape_p
Definition: MomentClip.h:171
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
const casacore::Vector< T > * pProfileSelect_p
Definition: MomentClip.h:165
virtual casacore::Bool canHandleNullMask() const
Can handle null mask.
Definition: MomentClip.h:157
virtual ~MomentClip()
Destructor (does nothing).
MomentsBase< T > & iMom_p
Definition: MomentClip.h:162
MomentClip(shared_ptr< casacore::Lattice< T >> pAncilliaryLattice, MomentsBase< T > &iMom, casacore::LogIO &os, const casacore::uInt nLatticeOut)
Constructor.
virtual void multiProcess(casacore::Vector< T > &out, casacore::Vector< casacore::Bool > &outMask, const casacore::Vector< T > &in, const casacore::Vector< casacore::Bool > &inMask, const casacore::IPosition &pos)
This function returns a vector of numbers from each input vector.
Computes simple clipped, and masked moments.
Definition: MomentClip.h:123
unsigned int uInt
Definition: aipstype.h:51
casacore::Bool doExclude_p
Definition: MomentClip.h:169