ImageStatsCalculator.h

Go to the documentation of this file.
00001 //# tSubImage.cc: Test program for class SubImage
00002 //# Copyright (C) 1998,1999,2000,2001,2003
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This program is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU General Public License as published by the Free
00007 //# Software Foundation; either version 2 of the License, or (at your option)
00008 //# any later version.
00009 //#
00010 //# This program 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 General Public License for
00013 //# more details.
00014 //#
00015 //# You should have received a copy of the GNU General Public License along
00016 //# with this program; if not, write to the Free Software Foundation, Inc.,
00017 //# 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: tSubImage.cc 20567 2009-04-09 23:12:39Z gervandiepen $
00027 
00028 #ifndef IMAGEANALYSIS_IMAGESTATSCALCULATOR_H
00029 #define IMAGEANALYSIS_IMAGESTATSCALCULATOR_H
00030 
00031 #include <imageanalysis/ImageAnalysis/ImageTask.h>
00032 
00033 #include <images/Images/ImageStatistics.h>
00034 //#include <casa/Utilities/CountedPtr.h>
00035 #include <casa/namespace.h>
00036 
00037 #include <memory>
00038 
00039 namespace casa {
00040 
00041 template <class T> class CountedPtr;
00042 
00043 class ImageStatsCalculator: public ImageTask<Float> {
00044     // <summary>
00045     // Top level class used for statistics calculations
00046     // </summary>
00047 
00048     // <reviewed reviewer="" date="" tests="" demos="">
00049     // </reviewed>
00050 
00051     // <prerequisite>
00052     // </prerequisite>
00053 
00054     // <etymology>
00055     // Image statistics calculator
00056     // </etymology>
00057 
00058     // <synopsis>
00059     // Top level class used for statistics calculations
00060     // </synopsis>
00061 
00062 public:
00063 
00064         enum PreferredClassicalAlgorithm {
00065                 // old algorithm
00066                 TILED_APPLY,
00067                 // new algorithm
00068                 STATS_FRAMEWORK,
00069                 // decide based on size and number of steps needed for
00070                 // stats
00071                 AUTO
00072         };
00073 
00074         ImageStatsCalculator(
00075                 const SPCIIF image,
00076         const Record *const &regionPtr,
00077         const String& maskInp, Bool beVerboseDuringConstruction=False
00078     );
00079 
00080     ~ImageStatsCalculator();
00081 
00082     Record calculate();
00083 
00084     void configureChauvenet(Double zscore, Int maxIterations);
00085 
00086     void configureClassical(PreferredClassicalAlgorithm p);
00087 
00088     // configure fit to half algorithm
00089     void configureFitToHalf(
00090         FitToHalfStatisticsData::CENTER centerType,
00091         FitToHalfStatisticsData::USE_DATA useData,
00092         Double centerValue
00093     );
00094 
00095     // configure hinges-fences algorithm
00096     void configureHingesFences(Double f);
00097 
00098     void forceNewStorage() { _statistics.reset(); }
00099 
00100     inline String getClass() const {return _class;}
00101 
00102     inline void setAxes(const Vector<Int>& axes) {
00103         _axes.assign(axes); GenSort<Int>::sort(_axes);
00104     }
00105 
00106     void setDisk(Bool d);
00107 
00108     // Set range of pixel values to include in the calculation. Should be a two element
00109     // Vector
00110     inline void setIncludePix(const Vector<Float>& inc) {_includepix.assign(inc);}
00111 
00112     // Set range of pixel values to exclude from the calculation. Should be a two element
00113     // Vector
00114     inline void setExcludePix(const Vector<Float>& exc) {_excludepix.assign(exc);}
00115 
00116     // List stats to logger? If you want no logging you should set this to False in addition to
00117     // calling setVerbosity()
00118     inline void setList(Bool l) {_list = l;}
00119 
00120     void setRobust(Bool r);
00121 
00122     void setVerbose(Bool v);
00123 
00124     // moved from ImageAnalysis
00125     // if messageStore != 0, log messages, stripped of time stampe and priority, will also
00126     // be placed in this parameter and returned to caller for eg logging to file.
00127     Record statistics(
00128          vector<String> *const &messageStore=0
00129     );
00130 
00131 protected:
00132 
00133         CasacRegionManager::StokesControl _getStokesControl() const {
00134                 return CasacRegionManager::USE_ALL_STOKES;
00135         }
00136 
00137     vector<OutputDestinationChecker::OutputStruct> _getOutputStruct() {
00138         return vector<OutputDestinationChecker::OutputStruct>(0);
00139     }
00140 
00141     vector<Coordinate::Type> _getNecessaryCoordinates() const {
00142         return vector<Coordinate::Type>(0);
00143     }
00144 
00145     Bool _hasLogfileSupport() const { return True; }
00146 
00147     inline Bool _supportsMultipleRegions() const {return True;}
00148 
00149 private:
00150     std::unique_ptr<ImageStatistics<Float> > _statistics;
00151     CountedPtr<ImageRegion> _oldStatsRegion, _oldStatsMask;
00152     Vector<Int> _axes;
00153     Vector<Float> _includepix, _excludepix;
00154     Bool _list, _disk, _robust, _verbose;
00155     LatticeStatistics<Float>::AlgConf _algConf;
00156     SHARED_PTR<const SubImage<Float> > _subImage;
00157     PreferredClassicalAlgorithm _prefClassStatsAlg;
00158 
00159     static const String _class;
00160 
00161     String _configureAlgorithm();
00162 
00163     // moved from ImageAnalysis
00164     // See if the combination of the 'region' and 'mask' ImageRegions have changed
00165     static Bool _haveRegionsChanged (
00166         ImageRegion* pNewRegionRegion,
00167         ImageRegion* pNewMaskRegion,
00168         ImageRegion* pOldRegionRegion,
00169         ImageRegion* pOldMaskRegion
00170     );
00171 
00172     void _reportDetailedStats(
00173         const SHARED_PTR<const ImageInterface<Float> > tempIm,
00174         const Record& retval
00175     );
00176 
00177 };
00178 }
00179 
00180 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1