00001 //# ImageSourceFinder.h: find sources in image 00002 //# Copyright (C) 1996,1997,1998,1999,2000,2001,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 addressed 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: ImageSourceFinder.h 20299 2008-04-03 05:56:44Z gervandiepen $ 00028 00029 #ifndef IMAGES_IMAGESOURCEFINDER_H 00030 #define IMAGES_IMAGESOURCEFINDER_H 00031 00032 #include <casa/aips.h> 00033 #include <measures/Measures/Stokes.h> 00034 #include <components/ComponentModels/ComponentType.h> 00035 #include <imageanalysis/ImageAnalysis/ImageTask.h> 00036 00037 namespace casa { //# NAMESPACE CASA - BEGIN 00038 00039 //# Forward Declarations 00040 template <class T> class ImageInterface; 00041 template <class T> class Vector; 00042 class ComponentList; 00043 class SkyComponent; 00044 class LogIO; 00045 00046 00047 // <summary> 00048 // Provides functionality to find sources in an image 00049 // </summary> 00050 00051 // <use visibility=export> 00052 00053 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos=""> 00054 // </reviewed> 00055 00056 // <prerequisite> 00057 // <li> <linkto class=ImageInterface>ImageInterface</linkto> 00058 // <li> <linkto module=Coordinates>Coordinates</linkto> 00059 // </prerequisite> 00060 00061 // <etymology> 00062 // It finds sources. 00063 // </etymology> 00064 00065 00066 // <synopsis> 00067 // This class provides methods to find sources in an image. 00068 // 00069 // The finding procedes in two stages. First, strong point sources 00070 // are found via an efficient algorithm producing POINT components. 00071 // If you wish, you can further request a Gaussian fit to these 00072 // found point sources and then return the parameters of the 00073 // fit (as a GAUSIAN component). 00074 // </synopsis> 00075 00076 // <example> 00077 // <srcBlock> 00078 // </srcBlock> 00079 // </example> 00080 00081 // <motivation> 00082 // This complements source fitting by providing an initial estimate 00083 // </motivation> 00084 00085 // <todo asof="2000/11/08"> 00086 // </todo> 00087 00088 00089 template <class T> class ImageSourceFinder : public ImageTask<T> { 00090 public: 00091 00092 ImageSourceFinder() = delete; 00093 00094 ImageSourceFinder(SPCIIT image, const Record *const region, const String& mask); 00095 00096 ImageSourceFinder (const ImageSourceFinder<T> &other) = delete; 00097 00098 ~ImageSourceFinder(); 00099 00100 ImageSourceFinder<T> &operator=(const ImageSourceFinder<T> &other) = delete; 00101 00102 // Find strong sources. nMax specifies the maximum number of sources to find. 00103 // cutoff is the fractional cutoff (of peak) and soiurces below this limit 00104 // will not be found. If absFind is True, only positive sources are found, else 00105 // positive and negative are found. If doPoint=True, the returned components 00106 // are of type POINT. If doPoint=False, the position and shape information is 00107 // returned via a Gaussian fit (and components will be of 00108 // type GAUSSIAN) to the point sources initially found. The parameter width 00109 // specifies the half-width of a square grid of pixels centered on the initial 00110 // point source location to be used in the fit. If you set doPoint=False and width=0, 00111 // a default width of 3 and position angle 0 is returned in the GAUSSIAN component. 00112 // Because the flux of the component is integrated, this rough shape influences the 00113 // flux values as well. 00114 ComponentList findSources (Int nMax); 00115 00116 // Find one source in sky plane. Exception if no sky 00117 SkyComponent findSourceInSky(Vector<Double>& absPixel); 00118 00119 void setCutoff(Double cutoff) { _cutoff = cutoff; } 00120 00121 void setAbsFind(Bool af) { _absFind = af; } 00122 00123 void setDoPoint(Bool dp) { _doPoint = dp; } 00124 00125 void setWidth(Int w) { _width = w; } 00126 00127 String getClass() const { 00128 const static String x = "ImageSourceFinder"; 00129 return x; 00130 } 00131 00132 protected: 00133 00134 CasacRegionManager::StokesControl _getStokesControl() const { 00135 return CasacRegionManager::USE_FIRST_STOKES; 00136 } 00137 00138 // Represents the minimum set of coordinates necessary for the 00139 // task to function. 00140 std::vector<Coordinate::Type> _getNecessaryCoordinates() const { 00141 return std::vector<Coordinate::Type>(1, Coordinate::DIRECTION); 00142 } 00143 00144 inline Bool _supportsMultipleRegions() const {return True;} 00145 00146 inline Bool _supportsMultipleBeams() const {return False;} 00147 00148 00149 private: 00150 Double _cutoff = 0.1; 00151 Bool _absFind = True; 00152 Bool _doPoint = True; 00153 Int _width = 4; 00154 00155 // Find strong (point) sources 00156 ComponentList _findSources(Int nMax); 00157 }; 00158 00159 00160 } 00161 00162 #ifndef CASACORE_NO_AUTO_TEMPLATES 00163 #include <imageanalysis/ImageAnalysis/ImageSourceFinder.tcc> 00164 #endif 00165 #endif