SDMaskHandler.h

Go to the documentation of this file.
00001 //# SDMaskHandler.h: Definition for SDMaskHandler
00002 //# Copyright (C) 1996,1997,1998,1999,2000,2002
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be adressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //#
00027 //# $Id$
00028 
00029 #ifndef SYNTHESIS_SDMASKHANDLER_H
00030 #define SYNTHESIS_SDMASKHANDLER_H
00031 
00032 #include <ms/MeasurementSets/MeasurementSet.h>
00033 #include <casa/Arrays/Matrix.h>
00034 #include <images/Images/ImageInterface.h>
00035 #include <images/Images/PagedImage.h>
00036 #include <images/Images/TempImage.h>
00037 #include <casa/Logging/LogMessage.h>
00038 #include <casa/Logging/LogSink.h>
00039 
00040 #include<synthesis/ImagerObjects/SIImageStore.h>
00041 #include<synthesis/ImagerObjects/SIImageStoreMultiTerm.h>
00042 #include <synthesis/ImagerObjects/InteractiveMasking.h>
00043 
00044 namespace casa { //# NAMESPACE CASA - BEGIN
00045 
00046 class SDMaskHandler 
00047 {
00048 public:
00049 
00050   // Empty constructor
00051   SDMaskHandler();
00052   ~SDMaskHandler();
00053 
00054   void resetMask(SHARED_PTR<SIImageStore> imstore);
00055 
00056   void fillMask(SHARED_PTR<SIImageStore> imstore, Vector<String> maskStrings);
00057   void fillMask(SHARED_PTR<SIImageStore> imstore, String maskString);
00058 
00059   // Collection of methods translate mask description (text, record, threshold, etc) to
00060   // mask image where the region(s) of interest are represented by the value (default = 1.0)
00061   // and the rest of the image is set to 0.0.
00062   //
00063   //void makeMask();
00064   // Create a mask image with maskName from tempim with a threshold applied to the pixel intensity
00065   SHARED_PTR<ImageInterface<Float> > makeMask(const String& maskName, const Quantity threshold, ImageInterface<Float>& tempim);
00066   
00067   // Make a mask image from Record, Matrix of (nboxes,4) where each row contains [blc_x,blc_y, trc_x,trc_y], 
00068   // and Matrix of (ncircles, 3) with the specified 'value'. Each row of circles are radius, x_center, y_center in pixels.
00069   // blctrcs and circles are applied to all the spectral and stokes while regions specified in record can specify selections 
00070   // in spectral and stokes axes.
00071   //static Bool regionToImageMask(const String& maskimage, Record* regionRec, Matrix<Quantity> & blctrcs,
00072   static Bool regionToImageMask(ImageInterface<Float>&  maskImage, Record* regionRec, Matrix<Quantity> & blctrcs,
00073                     Matrix<Float>& circles, const Float& value=1.0);
00074   
00075   // Convert boxes defined with blcs and trcs to ImageRegion
00076   static void boxRegionToImageRegion(const ImageInterface<Float>& maskImage, const Matrix<Quantity>& blctrcs, ImageRegion*& boxImageRegions);
00077   // Convert circles (in pixels)  to ImageRegion
00078   static void circleRegionToImageRegion(const ImageInterface<Float>& maskImage, const Matrix<Float>& circles, ImageRegion*& circleImageRegions);
00079   // Convert region defined by record to Imageregion
00080   static void recordRegionToImageRegion(Record* imageRegRec, ImageRegion*& imageRegion );
00081   // Convert ImageRegion to a mask image with the value
00082   static Bool regionToMask(ImageInterface<Float>& maskImage, ImageRegion& imageregion, const Float& value);
00083   // Read CRTF format text or the text file contains CRTF definitions and convert it to a ImageRegion
00084   static void regionTextToImageRegion(const String& text, const ImageInterface<Float>& regionImage, ImageRegion*& imageRegion);
00085 
00086   // merge mask images to outimage
00087   void copyAllMasks(const Vector< SHARED_PTR<ImageInterface<Float> > > inImageMasks, ImageInterface<Float>& outImageMask);
00088   // copy and regrid a mask image to outimage
00089   void copyMask(const ImageInterface<Float>& inimage, ImageInterface<Float>& outimage);
00090   // expand smaller chan mask image to larger one. - currently only works for a single channel (continuum) input mask 
00091   void expandMask(const ImageInterface<Float>& inImageMask, ImageInterface<Float>& outImageMask);
00092   // convert internal mask to imageRegion
00093   void InMaskToImageRegion(const ImageInterface<Float>& inimage );
00094 
00095   int makeInteractiveMask(SHARED_PTR<SIImageStore>& imstore,
00096                           Int& niter, Int& cycleniter,
00097                           String& threshold, String& cyclethreshold);
00098 
00099   // Return a reference to an imageinterface for the mask.
00100   void makeAutoMask(SHARED_PTR<SIImageStore> imstore);
00101   // Top level autoMask interface...
00102   void autoMask(SHARED_PTR<SIImageStore> imstore, 
00103                 const String& alg="",
00104                 const String& threshold="",
00105                 const Float& fracpeak=0.0,
00106                 const String& resolution="",
00107                 const Float& resbybeam=0.0,
00108                 const Int nmask=0, 
00109                 const Bool autoadjust=False,
00110                 Float pblimit=0.0);
00111   // automask algorithms...  
00112   void autoMaskByThreshold (ImageInterface<Float>& mask,
00113                            const ImageInterface<Float>& res, 
00114                            const ImageInterface<Float>& psf, 
00115                            const Quantity& resolution, 
00116                            const Float& resbybeam, 
00117                            const Quantity& qthreshold, 
00118                            const Float& fracofpeak, 
00119                            const Record& theStats,
00120                            const Float& sigma=3.0,
00121                            const Int nmask=0, 
00122                            const Bool autoadjust=False);
00123 
00124   // no binning version
00125   void autoMaskByThreshold2 (ImageInterface<Float>& mask,
00126                            const ImageInterface<Float>& res, 
00127                            const ImageInterface<Float>& psf, 
00128                            const Quantity& resolution, 
00129                            const Float& resbybeam, 
00130                            const Quantity& qthreshold, 
00131                            const Float& fracofpeak, 
00132                            const Record& theStats,
00133                            const Float& sigma=3.0,
00134                            const Int nmask=0);
00135                            
00136   SHARED_PTR<ImageInterface<Float> > makeMaskFromBinnedImage (
00137                                const ImageInterface<Float>& image, 
00138                                const Int nx, 
00139                                const Int ny,
00140                                const Float& fracofpeak,
00141                                const Float& sigma, 
00142                                const Int nmask,
00143                                const Bool autoadjust,
00144                                Double thresh=0.0);
00145 
00146   SHARED_PTR<ImageInterface<Float> > convolveMask(const ImageInterface<Float>& inmask, 
00147                                                   Int nxpix, Int nypix);
00148 
00149   SHARED_PTR<ImageInterface<Float> >  pruneRegions(const ImageInterface<Float>& image, 
00150                                                    Double& thresh, 
00151                                                    Int nmask=0, 
00152                                                    Int npix=0);
00153 
00154   void makePBMask(SHARED_PTR<SIImageStore> imstore, Float pblimit=0.1);
00155   void autoMaskWithinPB(SHARED_PTR<SIImageStore> imstore, 
00156                         const String& alg="",
00157                         const String& threshold="",
00158                         const Float& fracpeak=0.0,
00159                         const String& resolution="",
00160                         const Float& resbybeam=0.0,
00161                         const Int nmask=0,
00162                         const Bool autoadjust=False,
00163                         Float pblimit=0.1);
00164 
00165   // check if input image is a mask image with 0 or a value (if normalize=true, 1)
00166   Bool checkMaskImage(ImageInterface<Float>& maskiamge, Bool normalize=True);
00167 
00168 // 
00169   static Bool cloneImShape(const ImageInterface<Float>& inImage, const String& outImageName);
00170 
00171 protected:
00172   InteractiveMasking *interactiveMasker_p;
00173 
00174 private:
00175   Double itsRms;
00176   Double itsMax;
00177   Float itsSidelobeLevel;
00178 };
00179 
00180 
00181 
00182 } //# NAMESPACE CASA - END
00183 
00184 
00185 #endif
00186 
00187 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1