29 #ifndef SYNTHESIS_SDMASKHANDLER_H
30 #define SYNTHESIS_SDMASKHANDLER_H
42 #if ! defined(WITHOUT_DBUS)
56 void resetMask(std::shared_ptr<SIImageStore> imstore);
102 void makeAutoMask(std::shared_ptr<SIImageStore> imstore);
135 void autoMask(std::shared_ptr<SIImageStore> imstore,
420 #if ! defined(WITHOUT_DBUS)
A Vector of integers, for indexing into Array<T> objects.
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<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)
void makeAutoMask(std::shared_ptr< SIImageStore > imstore)
Return a reference to an imageinterface for the mask.
TableExprNode maxs(const TableExprNode &array, const TableExprNodeSet &collapseAxes)
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.
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)
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's automasking algorithm using multiple thresholds
A hierarchical collection of named fields of various types.
bool Bool
Define the standard types used by Casacore.
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
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)
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.
static void regionTextToImageRegion(const casacore::String &text, const casacore::ImageInterface< casacore::Float > ®ionImage, 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.
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)
Class to allow C++ expressions involving lattices.
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)