Source
xxxxxxxxxx
//# SDMaskHandler.h: Definition for SDMaskHandler
//# Copyright (C) 1996,1997,1998,1999,2000,2002
//# Associated Universities, Inc. Washington DC, USA.
//#
//# This library is free software; you can redistribute it and/or modify it
//# under the terms of the GNU Library General Public License as published by
//# the Free Software Foundation; either version 2 of the License, or (at your
//# option) any later version.
//#
//# This library is distributed in the hope that it will be useful, but WITHOUT
//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
//# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
//# License for more details.
//#
//# You should have received a copy of the GNU Library General Public License
//# along with this library; if not, write to the Free Software Foundation,
//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
//#
//# Correspondence concerning AIPS++ should be adressed as follows:
//# Internet email: aips2-request@nrao.edu.
//# Postal address: AIPS++ Project Office
//# National Radio Astronomy Observatory
//# 520 Edgemont Road
//# Charlottesville, VA 22903-2475 USA
//#
//#
//# $Id$
namespace casa { //# NAMESPACE CASA - BEGIN
class SDMaskHandler
{
public:
// Empty constructor
SDMaskHandler();
~SDMaskHandler();
void resetMask(std::shared_ptr<SIImageStore> imstore);
void fillMask(std::shared_ptr<SIImageStore> imstore, casacore::Vector<casacore::String> maskStrings);
void fillMask(std::shared_ptr<SIImageStore> imstore, casacore::String maskString);
// Collection of methods translate mask description (text, record, threshold, etc) to
// mask image where the region(s) of interest are represented by the value (default = 1.0)
// and the rest of the image is set to 0.0.
//
//void makeMask();
// Create a mask image with maskName from tempim with a threshold applied to the pixel intensity
std::shared_ptr<casacore::ImageInterface<casacore::Float> > makeMask(const casacore::String& maskName, const casacore::Quantity threshold, casacore::ImageInterface<casacore::Float>& tempim);
// Make a mask image from casacore::Record, casacore::Matrix of (nboxes,4) where each row contains [blc_x,blc_y, trc_x,trc_y],
// and casacore::Matrix of (ncircles, 3) with the specified 'value'. Each row of circles are radius, x_center, y_center in pixels.
// blctrcs and circles are applied to all the spectral and stokes while regions specified in record can specify selections
// in spectral and stokes axes.
//static casacore::Bool regionToImageMask(const casacore::String& maskimage, casacore::Record* regionRec, casacore::Matrix<casacore::Quantity> & blctrcs,
static casacore::Bool regionToImageMask(casacore::ImageInterface<casacore::Float>& maskImage, const casacore::Record* regionRec, const casacore::Matrix<casacore::Quantity> & blctrcs,
const casacore::Matrix<casacore::Float>& circles, const casacore::Float& value=1.0);
// Convert boxes defined with blcs and trcs to ImageRegion
static void boxRegionToImageRegion(const casacore::ImageInterface<casacore::Float>& maskImage, const casacore::Matrix<casacore::Quantity>& blctrcs, casacore::ImageRegion*& boxImageRegions);
// Convert circles (in pixels) to ImageRegion
static void circleRegionToImageRegion(const casacore::ImageInterface<casacore::Float>& maskImage, const casacore::Matrix<casacore::Float>& circles, casacore::ImageRegion*& circleImageRegions);
// Convert region defined by record to Imageregion
static void recordRegionToImageRegion(const casacore::Record* imageRegRec, casacore::ImageRegion*& imageRegion );
// Convert casacore::ImageRegion to a mask image with the value
static casacore::Bool regionToMask(casacore::ImageInterface<casacore::Float>& maskImage, casacore::ImageRegion& imageregion, const casacore::Float& value);
// Read CRTF format text or the text file contains CRTF definitions and convert it to a ImageRegion
static void regionTextToImageRegion(const casacore::String& text, const casacore::ImageInterface<casacore::Float>& regionImage, casacore::ImageRegion*& imageRegion);
// merge mask images to outimage
void copyAllMasks(const casacore::Vector< std::shared_ptr<casacore::ImageInterface<casacore::Float> > > inImageMasks, casacore::ImageInterface<casacore::Float>& outImageMask);
// copy and regrid a mask image to outimage
void copyMask(const casacore::ImageInterface<casacore::Float>& inimage, casacore::ImageInterface<casacore::Float>& outimage);