casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
StatImageCreator.h
Go to the documentation of this file.
1 #ifndef IMAGEANALYSIS_STATIMAGECREATOR_H
2 #define IMAGEANALYSIS_STATIMAGECREATOR_H
3 
5 
7 
8 #include <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.
39  SPCIIF image, const Record *const region, const String& mask,
40  const String& outname, Bool overwrite
41  );
42 
43  // destructor
45 
46  SPIIF compute();
47 
48  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
56 
57  // set spacing between grid pixels.
58  void setGridSpacing(uInt x, uInt y);
59 
60  // set interpolation algortihm
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);
71 
72  void setStatType(const String& s);
73 
74 protected:
75 
78  }
79 
80  inline std::vector<Coordinate::Type> _getNecessaryCoordinates() const {
81  return std::vector<Coordinate::Type>(1, Coordinate::DIRECTION);
82  }
83 
84  Bool _mustHaveSquareDirectionPixels() const { return false; }
85 
86  Bool _supportsMultipleBeams() const {return true;}
87 
88 private:
89 
90  Quantity _xlen = Quantity(1, "pix");
91  Quantity _ylen = Quantity(1, "pix");
92 
93  std::pair<uInt, uInt> _grid = std::make_pair(1,1);
94  // _anchor pixel world coordinates
98  String _interpName = "LINEAR";
99  casacore::String _statName = "standard deviation";
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(
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<
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(
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<
158  > _getStatsAlgorithm(String& algName) const;
159 
160 };
161 }
162 
163 #endif
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
void useReferencePixelAsAnchor()
rounds reference pixel to nearest ints, if necessary
void setRadius(const Quantity &radius)
set radius for circle subregion over which to carry out individual statistics computations.
int Int
Definition: aipstype.h:50
Temporary astronomical images.
casacore::String _statName
std::shared_ptr< StatisticsAlgorithm< Double, Array< Float >::const_iterator, Array< Bool >::const_iterator > > _getStatsAlgorithm(String &algName) const
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
void _interpolate(casacore::Matrix< casacore::Float > &result, casacore::Matrix< casacore::Bool > &resultMask, const casacore::Matrix< casacore::Float > &storage, const casacore::Matrix< casacore::Bool > &storeMask, const std::pair< casacore::uInt, casacore::uInt > &start) const
start is the pixel offset in the result matrix relative the storage matrix.
Quantum< Double > Quantity
Definition: Quantum.h:38
Bool _supportsMultipleBeams() const
does this task support images with multiple beams? false means it never does.
CasacRegionManager::StokesControl _getStokesControl() const
void setRectangle(const Quantity &xLength, const Quantity &yLength)
set a rectangular subregion over which to carry out individual statistics computations.
casacore::Interpolate2D _interpolater
double Double
Definition: aipstype.h:55
void setAnchorPosition(Int x, Int y)
set the anchor pixel value.
std::shared_ptr< const casacore::ImageInterface< casacore::Float > > SPCIIF
Definition: ImageTypedefs.h:50
void _computeStat(TempImage< Float > &writeTo, SPCIIF subImage, uInt nxpts, uInt nypts, Int xstart, Int ystart)
A hierarchical collection of named fields of various types.
Definition: Record.h:180
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
std::vector< Coordinate::Type > _getNecessaryCoordinates() const
Represents the minimum set of coordinates necessary for the task to function.
const Bool False
Definition: aipstype.h:44
Bool _mustHaveSquareDirectionPixels() const
StatImageCreator()=delete
Create a &quot;statistic&quot; image from an image.
void setGridSpacing(uInt x, uInt y)
set spacing between grid pixels.
~StatImageCreator()
destructor
Vector< Double > _anchor
_anchor pixel world coordinates
void setStatType(casacore::StatisticsData::STATS s)
void setStatType(casacore::LatticeStatsBase::StatisticsTypes s);
void setInterpAlgorithm(Interpolate2D::Method alg)
set interpolation algortihm
std::shared_ptr< casacore::ImageInterface< casacore::Float > > SPIIF
Definition: ImageTypedefs.h:51
A two dimension interpolator for Matrices or Arrays.
Definition: Interpolate2D.h:97
String getClass() const
std::pair< uInt, uInt > _grid
String: the storage and methods of handling collections of characters.
Definition: String.h:223
void _nominalChunkInfo(std::shared_ptr< Array< Bool >> &chunkMask, uInt &xBlcOff, uInt &yBlcOff, uInt &xChunkSize, uInt &yChunkSize, SPCIIF subimage) const
the Blc offsets are the pixel offsets from the grid point
void _doStatsLoop(casacore::TempImage< Float > &writeTo, casacore::RO_MaskedLatticeIterator< Float > &lattIter, casacore::uInt nxpts, casacore::uInt nypts, casacore::Int xstart, casacore::Int ystart, casacore::uInt xBlcOff, casacore::uInt yBlcOff, casacore::uInt xChunkSize, casacore::uInt yChunkSize, const casacore::IPosition &imshape, const casacore::IPosition &chunkShape, std::shared_ptr< casacore::Array< casacore::Bool >> regionMask, std::shared_ptr< casacore::StatisticsAlgorithm< casacore::Double, casacore::Array< casacore::Float >::const_iterator, casacore::Array< casacore::Bool >::const_iterator, casacore::Array< casacore::Float >::const_iterator > > &alg, const casacore::Array< casacore::Bool > &regMaskCopy, const casacore::IPosition &loopAxes, casacore::uInt nPts)
Base class of statistics algorithm class hierarchy.
casacore::StatisticsData::STATS _statType
unsigned int uInt
Definition: aipstype.h:51
void _doInterpolation(SPIIF output, TempImage< Float > &store, SPCIIF subImage, uInt nxpts, uInt nypts, Int xstart, Int ystart) const
A readonly iterator for masked Lattices.