LCOV - code coverage report
Current view: top level - imageanalysis/ImageAnalysis - StatImageCreator.h (source / functions) Hit Total Coverage
Test: casacpp_coverage.info Lines: 1 9 11.1 %
Date: 2024-12-11 20:54:31 Functions: 0 7 0.0 %

          Line data    Source code
       1             : #ifndef IMAGEANALYSIS_STATIMAGECREATOR_H
       2             : #define IMAGEANALYSIS_STATIMAGECREATOR_H
       3             : 
       4             : #include <imageanalysis/ImageAnalysis/ImageStatsBase.h>
       5             : 
       6             : #include <casacore/scimath/Mathematics/Interpolate2D.h>
       7             : 
       8             : #include <casacore/casa/namespace.h>
       9             : 
      10             : namespace casa {
      11             : 
      12             : class StatImageCreator : public ImageStatsBase<Float> {
      13             :         // <summary>
      14             :         // Create a "statistic" image from an image.
      15             :         // </summary>
      16             : 
      17             :         // <reviewed reviewer="" date="" tests="" demos="">
      18             :         // </reviewed>
      19             : 
      20             :         // <prerequisite>
      21             :         // </prerequisite>
      22             : 
      23             :         // <etymology>
      24             :         // </etymology>
      25             : 
      26             :         // <synopsis>
      27             :     // See CAS-9195.
      28             :         // </synopsis>
      29             : 
      30             : public:
      31             : 
      32             :         StatImageCreator() = delete;
      33             : 
      34             :         // <src>region</src> is the usual region used in image analysis tasks.
      35             :         // It is the region in the image over which to perform the computations.
      36             :         // The subregion over which to carry out a single statistic computation is
      37             :         // set separately after the object has been constructed.
      38             :         StatImageCreator(
      39             :                 SPCIIF image, const Record *const region, const String& mask,
      40             :                 const String& outname, Bool overwrite
      41             :         );
      42             : 
      43             :         // destructor
      44           0 :         ~StatImageCreator() {}
      45             : 
      46             :         SPIIF compute();
      47             : 
      48           0 :         String getClass() const { const static String s = "StatImageCreator"; return s; }
      49             : 
      50             :         // set the anchor pixel value. Note that this applies to the image used at construction,
      51             :         // not the resulting subimage if a region was also specified.
      52             :         void setAnchorPosition(Int x, Int y);
      53             : 
      54             :     // rounds reference pixel to nearest ints, if necessary
      55             :     void useReferencePixelAsAnchor();
      56             : 
      57             :         // set spacing between grid pixels.
      58             :         void setGridSpacing(uInt x, uInt y);
      59             : 
      60             :         // set interpolation algortihm
      61             :         void setInterpAlgorithm(Interpolate2D::Method alg);
      62             : 
      63             :         // set radius for circle subregion over which to carry out individual statistics computations.
      64             :         void setRadius(const Quantity& radius);
      65             : 
      66             :         // set a rectangular subregion over which to carry out individual statistics computations.
      67             :         void setRectangle(const Quantity& xLength, const Quantity& yLength);
      68             : 
      69             :         // void setStatType(casacore::LatticeStatsBase::StatisticsTypes s);
      70             :     void setStatType(casacore::StatisticsData::STATS s);
      71             : 
      72             :         void setStatType(const String& s);
      73             : 
      74             : protected:
      75             : 
      76           0 :         inline  CasacRegionManager::StokesControl _getStokesControl() const {
      77           0 :                 return CasacRegionManager::USE_ALL_STOKES;
      78             :         }
      79             : 
      80           0 :         inline std::vector<Coordinate::Type> _getNecessaryCoordinates() const {
      81           0 :                 return std::vector<Coordinate::Type>(1, Coordinate::DIRECTION);
      82             :         }
      83             : 
      84           0 :         Bool _mustHaveSquareDirectionPixels() const { return false; }
      85             : 
      86           0 :     Bool _supportsMultipleBeams() const {return true;}
      87             : 
      88             : private:
      89             : 
      90             :     Quantity _xlen = Quantity(1, "pix");
      91             :     Quantity _ylen = Quantity(1, "pix");
      92             : 
      93          34 :     std::pair<uInt, uInt> _grid = std::make_pair(1,1);
      94             :     // _anchor pixel world coordinates
      95             :     Vector<Double> _anchor;
      96             :     IPosition _dirAxes = IPosition(2);
      97             :     casacore::Interpolate2D _interpolater = Interpolate2D(Interpolate2D::LINEAR);
      98             :     String _interpName = "LINEAR";
      99             :     casacore::String _statName = "standard deviation";
     100             :     casacore::StatisticsData::STATS _statType
     101             :         = casacore::StatisticsData::STDDEV;
     102             :     casacore::Bool _doMask = casacore::False;
     103             :     casacore::Bool _doProbit = casacore::False;
     104             : 
     105             :     void _doInterpolation(
     106             :         SPIIF output, TempImage<Float>& store, SPCIIF subImage,
     107             :         uInt nxpts, uInt nypts, Int xstart, Int ystart
     108             :     ) const;
     109             : 
     110             :     void _computeStat(
     111             :         TempImage<Float>& writeTo, SPCIIF subImage, uInt nxpts,
     112             :         uInt nypts, Int xstart, Int ystart
     113             :     );
     114             : 
     115             :     void _doStatsLoop(
     116             :         casacore::TempImage<Float>& writeTo,
     117             :         casacore::RO_MaskedLatticeIterator<Float>& lattIter,
     118             :         casacore::uInt nxpts, casacore::uInt nypts, casacore::Int xstart,
     119             :         casacore::Int ystart, casacore::uInt xBlcOff, casacore::uInt yBlcOff,
     120             :         casacore::uInt xChunkSize, casacore::uInt yChunkSize,
     121             :         const casacore::IPosition& imshape,
     122             :         const casacore::IPosition& chunkShape,
     123             :         std::shared_ptr<casacore::Array<casacore::Bool>> regionMask,
     124             :         std::shared_ptr<
     125             :             casacore::StatisticsAlgorithm<
     126             :                 casacore::Double,
     127             :                 casacore::Array<casacore::Float>::const_iterator,
     128             :                 casacore::Array<casacore::Bool>::const_iterator,
     129             :                 casacore::Array<casacore::Float>::const_iterator
     130             :             >
     131             :         >& alg, const casacore::Array<casacore::Bool>& regMaskCopy,
     132             :         const casacore::IPosition& loopAxes, casacore::uInt nPts
     133             :     );
     134             : 
     135             :     // start is the pixel offset in the result matrix relative the
     136             :     // storage matrix. If one or both values are 0, then pixel 0 of the
     137             :     // result matrix corresponds to pixel 0 in the storage matrix. If one or both
     138             :     // of the start values are positive, then pixel 0 in the result matrix
     139             :     // corresponds to pixel (start/pointsPerCell - 1) in the storage matrix (which
     140             :     // is always negative and always greater than -1).
     141             :     void _interpolate(
     142             :         casacore::Matrix<casacore::Float>& result,
     143             :         casacore::Matrix<casacore::Bool>& resultMask,
     144             :         const casacore::Matrix<casacore::Float>& storage,
     145             :         const casacore::Matrix<casacore::Bool>& storeMask,
     146             :         const std::pair<casacore::uInt, casacore::uInt>& start
     147             :     ) const;
     148             : 
     149             :     // the Blc offsets are the pixel offsets from the grid point
     150             :     void _nominalChunkInfo(
     151             :         std::shared_ptr<Array<Bool>>& chunkMask,
     152             :         uInt& xBlcOff, uInt& yBlcOff, uInt& xChunkSize, uInt& yChunkSize,
     153             :         SPCIIF subimage
     154             :     ) const;
     155             : 
     156             :     std::shared_ptr<StatisticsAlgorithm<
     157             :         Double, Array<Float>::const_iterator, Array<Bool>::const_iterator>
     158             :     > _getStatsAlgorithm(String& algName) const;
     159             : 
     160             : };
     161             : }
     162             : 
     163             : #endif

Generated by: LCOV version 1.16