casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PixelValueManipulator.h
Go to the documentation of this file.
1 #ifndef IMAGEANALYSIS_PIXELVALUEMANIPULATOR_H
2 #define IMAGEANALYSIS_PIXELVALUEMANIPULATOR_H
3 
5 
8 
9 namespace casa {
10 
11 template <class T> class PixelValueManipulator : public ImageTask<T> {
12  // <summary>
13  // Top level interface for getting and setting image pixel values.
14  // </summary>
15 
16  // <reviewed reviewer="" date="" tests="" demos="">
17  // </reviewed>
18 
19  // <prerequisite>
20  // </prerequisite>
21 
22  // <etymology>
23  // Manipulates pixel values.
24  // </etymology>
25 
26  // <synopsis>
27  // Top level interface for getting and setting image pixel values.
28  // </synopsis>
29 
30  // <example>
31  // </example>
32 
33 public:
34 
35  enum Operator {
41  };
42 
43  PixelValueManipulator() = delete;
44 
45  // regionRec = 0 => no region selected, full image used
46  // mask = "" => No additional mask specification, although image default
47  // mask will be used if one exists.
49  const SPCIIT image, const casacore::Record *const regionRec,
50  const casacore::String& mask,
51  casacore::Bool verboseDuringConstruction=casacore::True
52  );
53 
55 
56  static void addNoise(
57  SPIIT image, const casacore::String& type,
58  const casacore::Record& region,
60  casacore::Bool zero,
61  const std::pair<casacore::Int, casacore::Int> *const &seeds
62  );
63 
64  // <src>dirFrame</src> and <src>freqFrame</src> are the codes for the
65  // frames for which it is desired that the returned measures should be
66  // specified. In both cases, one can specify "native" for the native
67  // coordinate frame, "cl" for the conversion layer frame, or any valid frame
68  // string from casacore::MDirection::showType() or MFrequency::showType().
70  casacore::Quantum<T>& intensity, casacore::Record& direction,
71  casacore::Record& frequency, casacore::Record& velocity,
72  SPCIIT image, const casacore::Vector<casacore::Double>& pixel,
73  const casacore::String& dirFrame, const casacore::String& freqFrame
74  );
75 
76  // set axes to average over. If invert is true, select all axes other than
77  // the specified axes to average over.
78  void setAxes(const casacore::IPosition& axes, casacore::Bool invert=false);
79 
80  // Get pixel values, pixel mask values, etc.
81  // The return casacore::Record has the following fields:
82  // 'values' => casacore::Array<T> of pixel values
83  // 'mask' => casacore::Array<casacore::Bool> of pixel mask values
84  casacore::Record get() const;
85 
86  // get a slice through the image. The values are interpolated at regular
87  // intervals to provide samples at npts number of points. x and y are
88  // in pixel coordinates
89 
90  static casacore::Record* getSlice(
95  casacore::Int npts=0, const casacore::String& method="linear"
96  );
97 
98  static void put(
99  SPIIT image, const casacore::Array<T>& pixelsArray,
102  casacore::Bool locking, casacore::Bool replicate
103  );
104 
105  static casacore::Bool putRegion(
106  SPIIT image, const casacore::Array<T>& pixels,
108  casacore::Record& region, casacore::Bool list,
109  casacore::Bool usemask, casacore::Bool replicateArray
110  );
111 
112  // get the aggregated values along the specified pixel axis using the region
113  // and mask at construction and any other mask the image may have. Supported
114  // values of <src>function</src> are (case-insensitive, minimum match) those
115  // supported by ImageCollapser, ie "flux", "max", "mean", "median", "min",
116  // "rms", "sqrtsum", "sqrtsum_npix", sqrtsum_npix_beam", "stddev", "sum",
117  // "variance", and "zero". Aggregation of values occurs along all axes
118  // orthogonal to the one specified. One may specify the unit in which
119  // coordinate values are calculated using the <src>unit</src> parameter. If
120  // unit starts with "pix", then pixel coordinates are calculated, world
121  // coordinates otherwise. If pixel coordinates, the values are relative to
122  // the zeroth pixel on the corresponding axis of the input image. If
123  // specified and it doesn't start with "pix", the unit must be conformant
124  // with the unit of <src>axis</src> in the coordinate system of the image,
125  // or it must be a unit that this axis can be readily converted to (eg km/s
126  // if the axis is a frequency axis with base unit of Hz). If the selected
127  // axis is the spectral axis and if the unit is chosen to be something other
128  // than the native spectral coordinate unit (such as velocity or wavelength
129  // for a native frequency unit), <src>specType</src> indicates the system to
130  // use when converting the frequency. Values of RELATVISTIC, RADIO_VELOCITY,
131  // and OPTICAL_VELOCITY are only permitted if <src>unit</src> represents a
132  // velocity unit. Values of WAVELENGTH and AIR_WAVELENGTH are only permitted
133  // if <src>unit</src> represents a length unit. For a velocity unit, DEFAULT
134  // is equivalent to RELATIVISTIC. For a length unit, DEFAULT is equivalent
135  // to WAVELENGTH.
136  // If the selected axis is the spectral axis and <src>unit</src> is a
137  // velocity unit, <src>restFreq</src> represents the rest frequency with
138  // respect to which the velocity scale should be calculated. If null, the
139  // rest frequency associated with the spectral coordinate is used. If the
140  // selected axis is the spectral axis, and <src>unit</src> is a frequency
141  // unit, <src>frame</src> represents the frame of reference with respect to
142  // which the frequency scale should be calculated. If empty, the reference
143  // frame associated with the spectral coordinate is used. The return Record
144  // has the following keys: "values" is a casacore::Vector<T> containing the
145  // aggregate pixel values, "mask" is the associated mask values
146  // (Vector<Bool>), "coords" is a casacore::Vector<casacore::Double> of
147  // coordinate values, and "xUnit" is a casacore::String containing the
148  // coordinate unit, and "yUnit" is a string containing the ordinate unit.
150  casacore::uInt axis, const casacore::String& function,
151  const casacore::String& unit,
154  const casacore::Quantity *const restFreq=nullptr,
155  const casacore::String& frame=""
156  );
157 
160  const casacore::String& unit,
163  const casacore::Quantity *const restFreq=nullptr,
164  const casacore::String& frame=""
165  );
166 
168 
169  // region refers to the region in the image to be inserted, not the region
170  // that was chosen at object construction
171  static void insert(
173  const casacore::ImageInterface<T>& image,
174  const casacore::Record& region,
175  const casacore::Vector<casacore::Double>& locatePixel,
176  casacore::Bool verbose
177  );
178 
179  // Make a block of regions from a Record
180  // public so ImageAnalysis can use it, once those methods have been
181  // excised, make private
182  static void makeRegionBlock(
184  const casacore::Record& Regions
185  );
186 
189  ) const;
190 
191  void pixelValue(
194  ) const;
195 
196  // set specified pixels or mask equal to provided scalar value
197  static casacore::Bool set(
198  SPIIF image, const casacore::String& pixels,
199  const casacore::Int pixelmask, casacore::Record& region,
200  const casacore::Bool list = false
201  );
202 
203  // set region name for logging purposes. Only used if the logfile is set.
204  void setRegionName(const casacore::String& rname) { _regionName = rname; }
205 
206 protected:
209  }
210 
211  std::vector<casacore::Coordinate::Type> _getNecessaryCoordinates() const {
212  return std::vector<casacore::Coordinate::Type>();
213  }
214 
215  casacore::Bool _hasLogfileSupport() const { return true; }
216 
218 
219 private:
223 
224  void _checkUnit(
225  const casacore::String& unit, const casacore::CoordinateSystem& csys,
227  ) const;
228 
230  casacore::uInt axis, const casacore::String& function, Operator op
231  ) const;
232 
234  casacore::uInt axis, const casacore::String& function
235  ) const;
236 
238  SPIIT collapsed, const casacore::String& unit,
240  const casacore::Quantity *const restFreq, const casacore::String& frame,
241  casacore::uInt axis
242  ) const;
243 
246  const casacore::CoordinateSystem& csys,
247  const casacore::String& unit,
249  const casacore::Quantity *const restFreq,
250  const casacore::String& axisUnit
251  ) const;
252 
254 };
255 
256 }
257 
258 #ifndef AIPS_NO_TEMPLATE_SRC
259 #include <imageanalysis/ImageAnalysis/PixelValueManipulator.tcc>
260 #endif //# AIPS_NO_TEMPLATE_SRC
261 
262 #endif
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
int Int
Definition: aipstype.h:50
casacore::Record getProfile(casacore::uInt axis, const casacore::String &function, const casacore::String &unit, PixelValueManipulatorData::SpectralType specType=PixelValueManipulatorData::DEFAULT, const casacore::Quantity *const restFreq=nullptr, const casacore::String &frame="")
get the aggregated values along the specified pixel axis using the region and mask at construction an...
SPIIT _doSingle(casacore::uInt axis, const casacore::String &function) const
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
AggregateType
Non-templated data related bits for ImageCollapser.
casacore::Record pixelValue(const casacore::Vector< casacore::Int > &pixel) const
virtual Type type()
Return the type enum.
static void put(SPIIT image, const casacore::Array< T > &pixelsArray, const casacore::Vector< casacore::Int > &blc, const casacore::Vector< casacore::Int > &inc, casacore::Bool list, casacore::Bool locking, casacore::Bool replicate)
casacore::Record _doWorld(SPIIT collapsed, const casacore::String &unit, PixelValueManipulatorData::SpectralType specType, const casacore::Quantity *const restFreq, const casacore::String &frame, casacore::uInt axis) const
static void makeRegionBlock(casacore::PtrBlock< const casacore::ImageRegion * > &regions, const casacore::Record &Regions)
Make a block of regions from a Record public so ImageAnalysis can use it, once those methods have bee...
void setAxes(const casacore::IPosition &axes, casacore::Bool invert=false)
set axes to average over.
SPIIT _doComposite(casacore::uInt axis, const casacore::String &function, Operator op) const
static const casacore::String _className
void setRegionName(const casacore::String &rname)
set region name for logging purposes.
static void insert(casacore::ImageInterface< T > &target, const casacore::ImageInterface< T > &image, const casacore::Record &region, const casacore::Vector< casacore::Double > &locatePixel, casacore::Bool verbose)
region refers to the region in the image to be inserted, not the region that was chosen at object con...
casacore::Vector< casacore::uInt > _npts(casacore::uInt axis) const
A base class for astronomical images.
#define SPIIT
Definition: ImageTypedefs.h:34
Operator
Top level interface for getting and setting image pixel values.
void _doNoncomformantUnit(casacore::Vector< casacore::Double > &coords, const casacore::CoordinateSystem &csys, const casacore::String &unit, PixelValueManipulatorData::SpectralType specType, const casacore::Quantity *const restFreq, const casacore::String &axisUnit) const
casacore::Bool _hasLogfileSupport() const
by default, derived classes are configured to have no log file support.
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
Quantities (i.e. dimensioned values)
Definition: QuantumHolder.h:44
#define SPCIIT
Definition: ImageTypedefs.h:35
A drop-in replacement for Block&lt;T*&gt;.
Definition: WProjectFT.h:54
template &lt;class T, class U&gt; class vector;
Definition: MSFlagger.h:37
static casacore::Bool putRegion(SPIIT image, const casacore::Array< T > &pixels, const casacore::Array< casacore::Bool > &mask, casacore::Record &region, casacore::Bool list, casacore::Bool usemask, casacore::Bool replicateArray)
std::shared_ptr< casacore::ImageInterface< casacore::Float > > SPIIF
Definition: ImageTypedefs.h:51
static casacore::Record * coordMeasures(casacore::Quantum< T > &intensity, casacore::Record &direction, casacore::Record &frequency, casacore::Record &velocity, SPCIIT image, const casacore::Vector< casacore::Double > &pixel, const casacore::String &dirFrame, const casacore::String &freqFrame)
dirFrame and freqFrame are the codes for the frames for which it is desired that the returned measure...
std::vector< casacore::Coordinate::Type > _getNecessaryCoordinates() const
Represents the minimum set of coordinates necessary for the task to function.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
SpectralType
Non-templated data related bits for PixelValueManipulator.
casacore::Bool _supportsMultipleRegions() const
static casacore::Bool set(SPIIF image, const casacore::String &pixels, const casacore::Int pixelmask, casacore::Record &region, const casacore::Bool list=false)
set specified pixels or mask equal to provided scalar value
void _checkUnit(const casacore::String &unit, const casacore::CoordinateSystem &csys, PixelValueManipulatorData::SpectralType specType) const
casacore::String getClass() const
const Bool True
Definition: aipstype.h:43
static casacore::Record * getSlice(SPCIIT image, const casacore::Vector< casacore::Double > &x, const casacore::Vector< casacore::Double > &y, const casacore::Vector< casacore::Int > &axes, const casacore::Vector< casacore::Int > &coord, casacore::Int npts=0, const casacore::String &method="linear")
get a slice through the image.
Interconvert pixel and world coordinates.
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
CasacRegionManager::StokesControl _getStokesControl() const
unsigned int uInt
Definition: aipstype.h:51
static void addNoise(SPIIT image, const casacore::String &type, const casacore::Record &region, const casacore::Vector< casacore::Double > &pars, casacore::Bool zero, const std::pair< casacore::Int, casacore::Int > *const &seeds)