00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
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 {
00045
00046 class SDMaskHandler
00047 {
00048 public:
00049
00050
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
00060
00061
00062
00063
00064
00065 SHARED_PTR<ImageInterface<Float> > makeMask(const String& maskName, const Quantity threshold, ImageInterface<Float>& tempim);
00066
00067
00068
00069
00070
00071
00072 static Bool regionToImageMask(ImageInterface<Float>& maskImage, Record* regionRec, Matrix<Quantity> & blctrcs,
00073 Matrix<Float>& circles, const Float& value=1.0);
00074
00075
00076 static void boxRegionToImageRegion(const ImageInterface<Float>& maskImage, const Matrix<Quantity>& blctrcs, ImageRegion*& boxImageRegions);
00077
00078 static void circleRegionToImageRegion(const ImageInterface<Float>& maskImage, const Matrix<Float>& circles, ImageRegion*& circleImageRegions);
00079
00080 static void recordRegionToImageRegion(Record* imageRegRec, ImageRegion*& imageRegion );
00081
00082 static Bool regionToMask(ImageInterface<Float>& maskImage, ImageRegion& imageregion, const Float& value);
00083
00084 static void regionTextToImageRegion(const String& text, const ImageInterface<Float>& regionImage, ImageRegion*& imageRegion);
00085
00086
00087 void copyAllMasks(const Vector< SHARED_PTR<ImageInterface<Float> > > inImageMasks, ImageInterface<Float>& outImageMask);
00088
00089 void copyMask(const ImageInterface<Float>& inimage, ImageInterface<Float>& outimage);
00090
00091 void expandMask(const ImageInterface<Float>& inImageMask, ImageInterface<Float>& outImageMask);
00092
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
00100 void makeAutoMask(SHARED_PTR<SIImageStore> imstore);
00101
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
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
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
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 }
00183
00184
00185 #endif
00186
00187