casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SDMaskHandler.h
Go to the documentation of this file.
1 //# SDMaskHandler.h: Definition for SDMaskHandler
2 //# Copyright (C) 1996,1997,1998,1999,2000,2002
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 adressed 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 //#
27 //# $Id$
28 
29 #ifndef SYNTHESIS_SDMASKHANDLER_H
30 #define SYNTHESIS_SDMASKHANDLER_H
31 
33 #include <casa/Arrays/Matrix.h>
38 #include <casa/Logging/LogSink.h>
39 
42 #if ! defined(WITHOUT_DBUS)
44 #endif
45 
46 namespace casa { //# NAMESPACE CASA - BEGIN
47 
49 {
50 public:
51 
52  // Empty constructor
53  SDMaskHandler();
55 
56  void resetMask(std::shared_ptr<SIImageStore> imstore);
57 
58  void fillMask(std::shared_ptr<SIImageStore> imstore, casacore::Vector<casacore::String> maskStrings);
59  void fillMask(std::shared_ptr<SIImageStore> imstore, casacore::String maskString);
60 
61  // Collection of methods translate mask description (text, record, threshold, etc) to
62  // mask image where the region(s) of interest are represented by the value (default = 1.0)
63  // and the rest of the image is set to 0.0.
64  //
65  //void makeMask();
66  // Create a mask image with maskName from tempim with a threshold applied to the pixel intensity
67  std::shared_ptr<casacore::ImageInterface<casacore::Float> > makeMask(const casacore::String& maskName, const casacore::Quantity threshold, casacore::ImageInterface<casacore::Float>& tempim);
68 
69  // Make a mask image from casacore::Record, casacore::Matrix of (nboxes,4) where each row contains [blc_x,blc_y, trc_x,trc_y],
70  // and casacore::Matrix of (ncircles, 3) with the specified 'value'. Each row of circles are radius, x_center, y_center in pixels.
71  // blctrcs and circles are applied to all the spectral and stokes while regions specified in record can specify selections
72  // in spectral and stokes axes.
73  //static casacore::Bool regionToImageMask(const casacore::String& maskimage, casacore::Record* regionRec, casacore::Matrix<casacore::Quantity> & blctrcs,
76 
77  // Convert boxes defined with blcs and trcs to ImageRegion
79  // Convert circles (in pixels) to ImageRegion
81  // Convert region defined by record to Imageregion
82  static void recordRegionToImageRegion(casacore::Record* imageRegRec, casacore::ImageRegion*& imageRegion );
83  // Convert casacore::ImageRegion to a mask image with the value
85  // Read CRTF format text or the text file contains CRTF definitions and convert it to a ImageRegion
86  static void regionTextToImageRegion(const casacore::String& text, const casacore::ImageInterface<casacore::Float>& regionImage, casacore::ImageRegion*& imageRegion);
87 
88  // merge mask images to outimage
90  // copy and regrid a mask image to outimage
92  // expand smaller chan mask image to larger one. - currently only works for a single channel (continuum) input mask
94  // convert internal mask to imageRegion
96 
97  int makeInteractiveMask(std::shared_ptr<SIImageStore>& imstore,
98  casacore::Int& niter, casacore::Int& cycleniter,
99  casacore::String& threshold, casacore::String& cyclethreshold);
100 
101  // Return a reference to an imageinterface for the mask.
102  void makeAutoMask(std::shared_ptr<SIImageStore> imstore);
103  // Top level autoMask interface
104  // Different automasking algorithm can be choosen by specifying a specific alogrithm name in alg.
105  // Not all arguments are used for a choosen alogrithm.
106  //
107  //
108  // @param[in,out] imstore SIImageStore
109  // @param[in,out] positive only mask
110  // @param[in] current iteration number completed
111  // @param[in, out] channel flag
112  // @param[in, out] robust image statistics
113  // @param[in] alg autoboxing alogrithm name (currently recongnized names are 'one-box', 'thresh','thresh2', and 'multithresh')
114  // @param[in] threshold threshold with a unit
115  // @param[in] fracpeak Fraction of the peak
116  // @param[in] resolution Resolution with a unit
117  // @param[in] resbybeam Multiplier of a beam to specify the resolution
118  // @param[in] nmask Number of masks to use
119  // @param[in] autoadjust Use autoadjustment of mask threshold (for 'thresh')
120  // @param[in] sidlobethreshold Threshold factor in a multiplier of the sidelobe level
121  // @param[in] noisethreshold Threshold factor in a multiplier of the rms noise
122  // @param[in] lownoisethreshold Threshold factor in a multiplier of the rms noise used in the binary dilation
123  // @param[in] negativethreshold Threshold factor in a multiplier of the rms noise used to set threshold for negative features
124  // @param[in] cutthreshold Cut threshold factor for adjust a mask after smoothing of the mask
125  // @param[in] smoothfactor Smoothing factor (multiplier of the beam)
126  // @param[in] minbeamfrac Percent change in mask size to trigger a new automask creation for 'noise'-based threshold
127  // @param[in] growiterations (maximum) number of binary dilation iteartions to grow the mask
128  // @param[in] dogrowprune Toggle to do or skip pruning on the grow mask
129  // @param[in] minpercentchange Mininum percentage change in mask to stop updating mask
130  // @param[in] verbose Controls automask related logging messages
131  // @param[in] isthresholdreached Check if cyclethreshold reached threshold
132  // @param[in] fastnoise Toggle to turn on and off fast (but less robust) noise calculation
133  // @param[in] pblimit Primary beam cut off level
134  //
135  void autoMask(std::shared_ptr<SIImageStore> imstore,
137  const casacore::Int iterdone,
139  casacore::Record& robuststatsrec,
140  const casacore::String& alg="",
141  const casacore::String& threshold="",
142  const casacore::Float& fracpeak=0.0,
143  const casacore::String& resolution="",
144  const casacore::Float& resbybeam=0.0,
145  const casacore::Int nmask=0,
146  const casacore::Bool autoadjust=false,
147  const casacore::Float& sidelobethreshold=0.0,
148  const casacore::Float& noisethreshold=0.0,
149  const casacore::Float& lownoisethreshold=0.0,
150  const casacore::Float& negativethreshold=0.0,
151  const casacore::Float& cutthreshold=0.0,
152  const casacore::Float& smoothfactor=0.0,
153  const casacore::Float& minbeamfrac=0.0,
154  const casacore::Int growiterations=0,
155  const casacore::Bool dogrowprune=true,
156  const casacore::Float& minpercentchange=0.0,
157  const casacore::Bool verbose=false,
158  const casacore::Bool fastnoise=false,
159  const casacore::Bool isthresholdreached=false,
160  casacore::Float pblimit=0.0);
161 
162  // automask by threshold with binning before applying it
166  const casacore::Quantity& resolution,
167  const casacore::Float& resbybeam,
168  const casacore::Quantity& qthreshold,
169  const casacore::Float& fracofpeak,
170  const casacore::Record& theStatsffff,
171  const casacore::Float& sigma=3.0,
172  const casacore::Int nmask=0,
173  const casacore::Bool autoadjust=casacore::False);
174 
175  // automask by threshold : no binning version
179  const casacore::Quantity& resolution,
180  const casacore::Float& resbybeam,
181  const casacore::Quantity& qthreshold,
182  const casacore::Float& fracofpeak,
183  const casacore::Record& theStats,
184  const casacore::Float& sigma=3.0,
185  const casacore::Int nmask=0);
186 
187  // implementation of Amanda's automasking algorithm using multiple thresholds
192  const casacore::Record& stats,
193  const casacore::Record& newstats,
194  const casacore::Int iterdone,
196  const casacore::Float& maskPercentChange=0.0,
197  const casacore::Float& sidelobeLevel=0.0,
198  const casacore::Float& sidelobeThresholdFactor=3.0,
199  const casacore::Float& noiseThresholdFactor=3.0,
200  const casacore::Float& lowNoiseThresholdFactor=2.0,
201  const casacore::Float& negativeThresholdFactor=0.0,
202  const casacore::Float& cutThreshold=0.01,
203  const casacore::Float& smoothFactor=1.0,
204  const casacore::Float& minBeamFrac=-1.0,
205  const casacore::Int growIterations=100,
206  const casacore::Bool dogrowprune=true,
207  const casacore::Bool verbose=false,
208  const casacore::Bool isthresholdreached=false);
209 
210 
211  std::shared_ptr<casacore::ImageInterface<float> > makeMaskFromBinnedImage (
213  const casacore::Int nx,
214  const casacore::Int ny,
215  const casacore::Float& fracofpeak,
216  const casacore::Float& sigma,
217  const casacore::Int nmask,
218  const casacore::Bool autoadjust,
219  casacore::Double thresh=0.0);
220 
221  // Convolve mask image with nx pixel by ny pixel
222  std::shared_ptr<casacore::ImageInterface<float> > convolveMask(const casacore::ImageInterface<casacore::Float>& inmask,
223  casacore::Int nxpix, casacore::Int nypix);
224 
225  // Convolve mask image by a gaussian
226  std::shared_ptr<casacore::ImageInterface<float> > convolveMask(const casacore::ImageInterface<casacore::Float>& inmask,
227  const casacore::GaussianBeam& beam);
228 
229  // Prune the mask regions found
230  std::shared_ptr<casacore::ImageInterface<float> > pruneRegions(const casacore::ImageInterface<casacore::Float>& image,
231  casacore::Double& thresh,
232  casacore::Int nmask=0,
233  casacore::Int npix=0);
234  // Prune the mask regions per spectral plane
235  std::shared_ptr<casacore::ImageInterface<float> > pruneRegions2(const casacore::ImageInterface<casacore::Float>& image,
236  casacore::Double& thresh,
237  casacore::Int nmask=0,
238  casacore::Double prunesize=0.0);
239 
240  // Yet another Prune the mask regions per spectral plane
241  std::shared_ptr<casacore::ImageInterface<float> > YAPruneRegions(const casacore::ImageInterface<casacore::Float>& image,
246  casacore::Double prunesize=0.0,
247  casacore::Bool showchanlabel=true);
248 
249  // create a mask image (1/0 image) applying a different threshold for each channel plane
255 
256  // A core method for binary dilation of the input lattice
262 
263  // Multiple Binary dilation application of an image with a constraint mask and channel plane based flags
266  casacore::Int niteration,
270 
271  // return beam area in pixel unit
273 
274  // Create a mask image applying PB level
275  // @param[in, out] imstore SIImageStore
276  // @param[in] pblimit Primary beam cut off level
277  // @param[in] pblimit Primary beam cut off level
278  void makePBMask(std::shared_ptr<SIImageStore> imstore, casacore::Float pblimit=0.1, casacore::Bool combinemask=false);
279 
280  void autoMaskWithinPB(std::shared_ptr<SIImageStore> imstore,
282  const casacore::Int iterdone,
284  casacore::Record& robuststatsrec,
285  const casacore::String& alg="",
286  const casacore::String& threshold="",
287  const casacore::Float& fracpeak=0.0,
288  const casacore::String& resolution="",
289  const casacore::Float& resbybeam=0.0,
290  const casacore::Int nmask=0,
291  const casacore::Bool autoadjust=false,
292  const casacore::Float& sidelobethreshold=0.0,
293  const casacore::Float& noisethreshold=0.0,
294  const casacore::Float& lownoisethreshold=0.0,
295  const casacore::Float& negativethreshold=0.0,
296  const casacore::Float& cutthreshold=0.0,
297  const casacore::Float& smoothfactor=0.0,
298  const casacore::Float& minbeamfrac=0.0,
299  const casacore::Int growiterations=0,
300  const casacore::Bool dogrowprune=true,
301  const casacore::Float& minpercentchange=0.0,
302  const casacore::Bool verbose=false,
303  const casacore::Bool fastnoise=false,
304  const casacore::Bool isthresholdreached=false,
305  casacore::Float pblimit=0.1);
306 
307 
308  // depth-first-search algorithm for 2D
310  casacore::Int y,
311  casacore::Int cur_label,
314 
315  // non-recursive depth-first-search algorithm for 2D
317  casacore::Int y,
318  casacore::Int cur_label,
321 
322  // returns a Vector of neighboring pixels in IPosition (4-direction connectivity)
324  casacore::Int nrow,
325  casacore::Int ncol);
326 
327  // label connected regions using depth-first-search algorithm
329 
330 
331 
332  // find sizes of bolbs (regions) found by labelRegions
334 
335  // check if mask image is empty (all zeros ) =True or not
338 
339  // for warning messages for empy initial mask in automask
340  //void noMaskCheck(casacore::ImageInterface<casacore::Float>& mask, casacore::Vector<casacore::String>& thresholdType);
342 
343  // determining skip channels for the mask changed less than the specfied percentage
344  void skipChannels(const casacore::Float& fracChnage,
347  const casacore::Matrix<casacore::String>& threshtype,
348  const casacore::Bool isthresholdreached,
350  casacore::Vector<casacore::Bool>& zeroChanMask);
351 
352  // check if input image is a mask image with 0 or a value (if normalize=true, 1)
353  //casacore::Bool checkMaskImage(casacore::ImageInterface<casacore::Float>& maskiamge, casacore::Bool normalize=true);
354 
355  // print per-channel automask summary
360  //const casacore::Vector<casacore::Float>& maskthreshold,
361  const casacore::Matrix<casacore::Float>& maskthreshold,
362  //const casacore::Vector<casacore::String>& masktype,
363  const casacore::Matrix<casacore::String>& masktype,
364  const casacore::Vector<casacore::Bool>& chanflag,
365  //const casacore::Vector<casacore::Bool>& zerochanmask,
366  const casacore::Matrix<casacore::Bool>& zerochanmask,
367  //const casacore::Vector<casacore::uInt>& nreg,
369  //const casacore::Vector<casacore::uInt>& npruned,
370  const casacore::Matrix<casacore::uInt>& npruned,
371  //const casacore::Vector<casacore::uInt>& ngrowreg,
372  const casacore::Matrix<casacore::uInt>& ngrowreg,
373  //const casacore::Vector<casacore::uInt>& ngrowpruned,
374  const casacore::Matrix<casacore::uInt>& ngrowpruned,
375  //const casacore::Vector<casacore::Float>& negmaskpixs,
376  const casacore::Matrix<casacore::Float>& negmaskpixs,
377  const casacore::Record& miscsummaryinfo);
378 
379 
380  //
384  // max MB of memory to use in TempImage
385  static inline casacore::Double memoryToUse() {return 1.0;};
386 
387  // Calculate statistics on a residual image with additional region and LEL mask specifications
388  // using classical method
390  casacore::String& lelmask,
391  casacore::Record* regionPtr,
392  const casacore::Bool robust);
393 
394  // Calcuate statistics on a residual image using robust methods to estimate RMS noise.
395  // Basing on presence of a mask the following logic is used.
396  // a. If there is no existing clean mask, calculate statistics using the chauvenet algorithm with maxiter=5 and zscore=-1.
397  // b. If there is an existing clean mask, calculate the classic statistics with robust=True in the region outside the clean mask
398  // and inside the primary beam mask.
402  casacore::String& lelmask,
403  casacore::Record* regionPtr,
404  const casacore::Bool robust,
406 
410  casacore::String& lelmask,
411  casacore::Record* regionPtr,
412  const casacore::Bool robust,
414 
415  // Store pbmask level (a.k.a pblimit for mask)
416  void setPBMaskLevel(const casacore::Float pbmasklevel);
418 
419 protected:
420 #if ! defined(WITHOUT_DBUS)
422 #endif
423 
424 private:
425  double itsRms;
426  double itsMax;
429 };
430 
431 
432 
433 } //# NAMESPACE CASA - END
434 
435 
436 #endif
437 
438 
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
int Int
Definition: aipstype.h:50
static casacore::Record calcRobustImageStatisticsOld(casacore::ImageInterface< casacore::Float > &res, casacore::ImageInterface< casacore::Float > &prevmask, casacore::LatticeExpr< casacore::Bool > &pbmask, casacore::String &lelmask, casacore::Record *regionPtr, const casacore::Bool robust, casacore::Vector< casacore::Bool > &chanflag)
Calcuate statistics on a residual image using robust methods to estimate RMS noise.
void autoMaskByThreshold2(casacore::ImageInterface< casacore::Float > &mask, const casacore::ImageInterface< casacore::Float > &res, const casacore::ImageInterface< casacore::Float > &psf, const casacore::Quantity &resolution, const casacore::Float &resbybeam, const casacore::Quantity &qthreshold, const casacore::Float &fracofpeak, const casacore::Record &theStats, const casacore::Float &sigma=3.0, const casacore::Int nmask=0)
automask by threshold : no binning version
casacore::Bool compareSpectralCoordinate(const casacore::ImageInterface< casacore::Float > &inImage, const casacore::ImageInterface< casacore::Float > &outImage)
void noMaskCheck(casacore::ImageInterface< casacore::Float > &mask, casacore::Matrix< casacore::String > &thresholdType)
for warning messages for empy initial mask in automask void noMaskCheck(casacore::ImageInterface&lt;cas...
void makeMaskByPerChanThreshold(const casacore::ImageInterface< casacore::Float > &image, casacore::Vector< casacore::Bool > &chanflag, casacore::ImageInterface< casacore::Float > &mask, casacore::Vector< casacore::Float > &thresholds, casacore::Vector< casacore::Float > &masksizes)
create a mask image (1/0 image) applying a different threshold for each channel plane ...
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
static casacore::Bool regionToImageMask(casacore::ImageInterface< casacore::Float > &maskImage, casacore::Record *regionRec, casacore::Matrix< casacore::Quantity > &blctrcs, casacore::Matrix< casacore::Float > &circles, const casacore::Float &value=1.0)
Make a mask image from casacore::Record, casacore::Matrix of (nboxes,4) where each row contains [blc_...
void copyMask(const casacore::ImageInterface< casacore::Float > &inimage, casacore::ImageInterface< casacore::Float > &outimage)
copy and regrid a mask image to outimage
std::shared_ptr< casacore::ImageInterface< float > > pruneRegions2(const casacore::ImageInterface< casacore::Float > &image, casacore::Double &thresh, casacore::Int nmask=0, casacore::Double prunesize=0.0)
Prune the mask regions per spectral plane.
int makeInteractiveMask(std::shared_ptr< SIImageStore > &imstore, casacore::Int &niter, casacore::Int &cycleniter, casacore::String &threshold, casacore::String &cyclethreshold)
void makePBMask(std::shared_ptr< SIImageStore > imstore, casacore::Float pblimit=0.1, casacore::Bool combinemask=false)
Create a mask image applying PB level.
TableExprNode mins(const TableExprNode &array, const TableExprNodeSet &collapseAxes)
Definition: ExprNode.h:1687
void makeAutoMask(std::shared_ptr< SIImageStore > imstore)
Return a reference to an imageinterface for the mask.
TableExprNode maxs(const TableExprNode &array, const TableExprNodeSet &collapseAxes)
Definition: ExprNode.h:1693
A 2-D Specialization of the Array class.
casacore::Vector< casacore::Float > findBlobSize(casacore::Lattice< casacore::Float > &lablat)
find sizes of bolbs (regions) found by labelRegions
std::shared_ptr< casacore::ImageInterface< float > > YAPruneRegions(const casacore::ImageInterface< casacore::Float > &image, casacore::Vector< casacore::Bool > &chanflag, casacore::Vector< casacore::Bool > &allpruned, casacore::Vector< casacore::uInt > &nreg, casacore::Vector< casacore::uInt > &npruned, casacore::Double prunesize=0.0, casacore::Bool showchanlabel=true)
Yet another Prune the mask regions per spectral plane.
void depthFirstSearch2(casacore::Int x, casacore::Int y, casacore::Int cur_label, casacore::Array< casacore::Float > &inlatarr, casacore::Array< casacore::Float > &lablatarr)
non-recursive depth-first-search algorithm for 2D
std::shared_ptr< casacore::ImageInterface< float > > makeMaskFromBinnedImage(const casacore::ImageInterface< casacore::Float > &image, const casacore::Int nx, const casacore::Int ny, const casacore::Float &fracofpeak, const casacore::Float &sigma, const casacore::Int nmask, const casacore::Bool autoadjust, casacore::Double thresh=0.0)
void depthFirstSearch(casacore::Int x, casacore::Int y, casacore::Int cur_label, casacore::Array< casacore::Float > &inlatarr, casacore::Array< casacore::Float > &lablatarr)
depth-first-search algorithm for 2D
casacore::Float pixelBeamArea(const casacore::GaussianBeam &beam, const casacore::CoordinateSystem &csys)
return beam area in pixel unit
static casacore::Bool cloneImShape(const casacore::ImageInterface< casacore::Float > &inImage, const casacore::String &outImageName)
Represents a Gaussian restoring beam associated with an image.
Definition: GaussianBeam.h:68
void labelRegions(casacore::Lattice< casacore::Float > &inlat, casacore::Lattice< casacore::Float > &lablat)
label connected regions using depth-first-search algorithm
static casacore::Double memoryToUse()
max MB of memory to use in TempImage
void skipChannels(const casacore::Float &fracChnage, casacore::ImageInterface< casacore::Float > &prevmask, casacore::ImageInterface< casacore::Float > &curmask, const casacore::Matrix< casacore::String > &threshtype, const casacore::Bool isthresholdreached, casacore::Vector< casacore::Bool > &chanFlag, casacore::Vector< casacore::Bool > &zeroChanMask)
determining skip channels for the mask changed less than the specfied percentage
void copyAllMasks(const casacore::Vector< std::shared_ptr< casacore::ImageInterface< casacore::Float > > > inImageMasks, casacore::ImageInterface< casacore::Float > &outImageMask)
merge mask images to outimage
void autoMaskByThreshold(casacore::ImageInterface< casacore::Float > &mask, const casacore::ImageInterface< casacore::Float > &res, const casacore::ImageInterface< casacore::Float > &psf, const casacore::Quantity &resolution, const casacore::Float &resbybeam, const casacore::Quantity &qthreshold, const casacore::Float &fracofpeak, const casacore::Record &theStatsffff, const casacore::Float &sigma=3.0, const casacore::Int nmask=0, const casacore::Bool autoadjust=casacore::False)
automask by threshold with binning before applying it
void expandMask(const casacore::ImageInterface< casacore::Float > &inImageMask, casacore::ImageInterface< casacore::Float > &outImageMask)
expand smaller chan mask image to larger one.
void autoMaskWithinPB(std::shared_ptr< SIImageStore > imstore, casacore::TempImage< casacore::Float > &posmask, const casacore::Int iterdone, casacore::Vector< casacore::Bool > &chanflag, casacore::Record &robuststatsrec, const casacore::String &alg="", const casacore::String &threshold="", const casacore::Float &fracpeak=0.0, const casacore::String &resolution="", const casacore::Float &resbybeam=0.0, const casacore::Int nmask=0, const casacore::Bool autoadjust=false, const casacore::Float &sidelobethreshold=0.0, const casacore::Float &noisethreshold=0.0, const casacore::Float &lownoisethreshold=0.0, const casacore::Float &negativethreshold=0.0, const casacore::Float &cutthreshold=0.0, const casacore::Float &smoothfactor=0.0, const casacore::Float &minbeamfrac=0.0, const casacore::Int growiterations=0, const casacore::Bool dogrowprune=true, const casacore::Float &minpercentchange=0.0, const casacore::Bool verbose=false, const casacore::Bool fastnoise=false, const casacore::Bool isthresholdreached=false, casacore::Float pblimit=0.1)
static void recordRegionToImageRegion(casacore::Record *imageRegRec, casacore::ImageRegion *&imageRegion)
Convert region defined by record to Imageregion.
void resetMask(std::shared_ptr< SIImageStore > imstore)
double Double
Definition: aipstype.h:55
std::shared_ptr< casacore::ImageInterface< casacore::Float > > makeMask(const casacore::String &maskName, const casacore::Quantity threshold, casacore::ImageInterface< casacore::Float > &tempim)
Collection of methods translate mask description (text, record, threshold, etc) to mask image where t...
std::shared_ptr< casacore::ImageInterface< float > > convolveMask(const casacore::ImageInterface< casacore::Float > &inmask, casacore::Int nxpix, casacore::Int nypix)
Convolve mask image with nx pixel by ny pixel.
void autoMaskByMultiThreshold(casacore::ImageInterface< float > &mask, casacore::TempImage< casacore::Float > &posmask, const casacore::ImageInterface< casacore::Float > &res, const casacore::ImageInterface< casacore::Float > &psf, const casacore::Record &stats, const casacore::Record &newstats, const casacore::Int iterdone, casacore::Vector< casacore::Bool > &chanFlag, const casacore::Float &maskPercentChange=0.0, const casacore::Float &sidelobeLevel=0.0, const casacore::Float &sidelobeThresholdFactor=3.0, const casacore::Float &noiseThresholdFactor=3.0, const casacore::Float &lowNoiseThresholdFactor=2.0, const casacore::Float &negativeThresholdFactor=0.0, const casacore::Float &cutThreshold=0.01, const casacore::Float &smoothFactor=1.0, const casacore::Float &minBeamFrac=-1.0, const casacore::Int growIterations=100, const casacore::Bool dogrowprune=true, const casacore::Bool verbose=false, const casacore::Bool isthresholdreached=false)
implementation of Amanda&#39;s automasking algorithm using multiple thresholds
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
void fillMask(std::shared_ptr< SIImageStore > imstore, casacore::Vector< casacore::String > maskStrings)
InteractiveMasking * interactiveMasker_p
casacore::Bool isEmptyMask(casacore::ImageInterface< casacore::Float > &maskiamge)
check if mask image is empty (all zeros) =True or not
float Float
Definition: aipstype.h:54
static void boxRegionToImageRegion(const casacore::ImageInterface< casacore::Float > &maskImage, const casacore::Matrix< casacore::Quantity > &blctrcs, casacore::ImageRegion *&boxImageRegions)
Convert boxes defined with blcs and trcs to ImageRegion.
static casacore::Record calcRobustImageStatistics(casacore::ImageInterface< casacore::Float > &res, casacore::ImageInterface< casacore::Float > &prevmask, casacore::LatticeExpr< casacore::Bool > &pbmask, casacore::String &lelmask, casacore::Record *regionPtr, const casacore::Bool robust, casacore::Vector< casacore::Bool > &chanflag)
const Bool False
Definition: aipstype.h:44
void binaryDilationCore(casacore::Lattice< casacore::Float > &inlattice, casacore::Array< casacore::Float > &structure, casacore::Lattice< casacore::Bool > &mask, casacore::Array< casacore::Bool > &chanmask, casacore::Lattice< casacore::Float > &outlattice)
A core method for binary dilation of the input lattice.
casacore::Int getTotalPixels(casacore::ImageInterface< casacore::Float > &maskiamge)
void autoMask(std::shared_ptr< SIImageStore > imstore, casacore::TempImage< casacore::Float > &posmask, const casacore::Int iterdone, casacore::Vector< casacore::Bool > &chanflag, casacore::Record &robuststatsrec, const casacore::String &alg="", const casacore::String &threshold="", const casacore::Float &fracpeak=0.0, const casacore::String &resolution="", const casacore::Float &resbybeam=0.0, const casacore::Int nmask=0, const casacore::Bool autoadjust=false, const casacore::Float &sidelobethreshold=0.0, const casacore::Float &noisethreshold=0.0, const casacore::Float &lownoisethreshold=0.0, const casacore::Float &negativethreshold=0.0, const casacore::Float &cutthreshold=0.0, const casacore::Float &smoothfactor=0.0, const casacore::Float &minbeamfrac=0.0, const casacore::Int growiterations=0, const casacore::Bool dogrowprune=true, const casacore::Float &minpercentchange=0.0, const casacore::Bool verbose=false, const casacore::Bool fastnoise=false, const casacore::Bool isthresholdreached=false, casacore::Float pblimit=0.0)
Top level autoMask interface Different automasking algorithm can be choosen by specifying a specific ...
void InMaskToImageRegion(const casacore::ImageInterface< casacore::Float > &inimage)
convert internal mask to imageRegion
casacore::Float getPBMaskLevel()
Class to hold a region of interest in an image.
Definition: ImageRegion.h:86
static void regionTextToImageRegion(const casacore::String &text, const casacore::ImageInterface< casacore::Float > &regionImage, casacore::ImageRegion *&imageRegion)
Read CRTF format text or the text file contains CRTF definitions and convert it to a ImageRegion...
static casacore::Bool regionToMask(casacore::ImageInterface< casacore::Float > &maskImage, casacore::ImageRegion &imageregion, const casacore::Float &value)
Convert casacore::ImageRegion to a mask image with the value.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
void binaryDilation(casacore::ImageInterface< casacore::Float > &inImage, casacore::Array< casacore::Float > &structure, casacore::Int niteration, casacore::Lattice< casacore::Bool > &mask, casacore::Array< casacore::Bool > &chanmask, casacore::ImageInterface< casacore::Float > &outImage)
Multiple Binary dilation application of an image with a constraint mask and channel plane based flags...
std::shared_ptr< casacore::ImageInterface< float > > pruneRegions(const casacore::ImageInterface< casacore::Float > &image, casacore::Double &thresh, casacore::Int nmask=0, casacore::Int npix=0)
Prune the mask regions found.
static casacore::Record calcImageStatistics(casacore::ImageInterface< casacore::Float > &res, casacore::String &lelmask, casacore::Record *regionPtr, const casacore::Bool robust)
Calculate statistics on a residual image with additional region and LEL mask specifications using cla...
void printAutomaskSummary(const casacore::Array< casacore::Double > &rmss, const casacore::Array< casacore::Double > &maxs, const casacore::Array< casacore::Double > &mins, const casacore::Array< casacore::Double > &mdns, const casacore::Matrix< casacore::Float > &maskthreshold, const casacore::Matrix< casacore::String > &masktype, const casacore::Vector< casacore::Bool > &chanflag, const casacore::Matrix< casacore::Bool > &zerochanmask, const casacore::Matrix< casacore::uInt > &nreg, const casacore::Matrix< casacore::uInt > &npruned, const casacore::Matrix< casacore::uInt > &ngrowreg, const casacore::Matrix< casacore::uInt > &ngrowpruned, const casacore::Matrix< casacore::Float > &negmaskpixs, const casacore::Record &miscsummaryinfo)
check if input image is a mask image with 0 or a value (if normalize=true, 1) casacore::Bool checkMa...
TableExprNode rmss(const TableExprNode &array, const TableExprNodeSet &collapseAxes)
Definition: ExprNode.h:1723
Class to allow C++ expressions involving lattices.
Definition: LatticeExpr.h:142
void setPBMaskLevel(const casacore::Float pbmasklevel)
Store pbmask level (a.k.a pblimit for mask)
SDMaskHandler()
Empty constructor.
static void circleRegionToImageRegion(const casacore::ImageInterface< casacore::Float > &maskImage, const casacore::Matrix< casacore::Float > &circles, casacore::ImageRegion *&circleImageRegions)
Convert circles (in pixels) to ImageRegion.
Interconvert pixel and world coordinates.
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
casacore::Vector< casacore::IPosition > defineNeighbors(casacore::IPosition &pos, casacore::Int nrow, casacore::Int ncol)
returns a Vector of neighboring pixels in IPosition (4-direction connectivity)