casa
$Rev:20696$
|
00001 //# ImageConvolver.h: convolution of an image by array 00002 //# Copyright (C) 1996,1997,1998,1999,2000,2001,2003 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 //# $Id: ImageConvolver.h 20229 2008-01-29 15:19:06Z gervandiepen $ 00027 00028 #ifndef IMAGES_IMAGECONVOLVER_H 00029 #define IMAGES_IMAGECONVOLVER_H 00030 00031 00032 //# Includes 00033 #include <casa/aips.h> 00034 #include <casa/Logging/LogIO.h> 00035 #include <casa/Arrays/Array.h> 00036 00037 namespace casa { //# NAMESPACE CASA - BEGIN 00038 00039 //# Forward Declarations 00040 template <class T> class ImageInterface; 00041 template <class T> class Lattice; 00042 class CoordinateSystem; 00043 class String; 00044 00045 00046 00047 // <summary> 00048 // This class does convolution of an image by an Array or Lattice 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 class="LatticeConvolver">LatticeConvolver</linkto> 00059 // </prerequisite> 00060 00061 // <etymology> 00062 // This class handles convolution of images by an Array or Lattice 00063 // </etymology> 00064 00065 // <synopsis> 00066 // This class convolves an image by a specified kernel (Array or 00067 // Lattice). If the kernel does not have enough dimensions, degenerate 00068 // ones are added.The class object has no state. The functions could be static. 00069 // The convolution is done via FFT. Thus input pixels which 00070 // are masked are set to 0 before the convolution. The mask 00071 // is transferred to the output image. No additional scaling 00072 // of the output image values is done. 00073 // 00074 00075 // </synopsis> 00076 00077 // <example> 00078 // <srcBlock> 00079 // </srcBlock> 00080 // </example> 00081 00082 // <motivation> 00083 // Convolution is a standard image processing requirement. 00084 // </motivation> 00085 00086 // <todo asof="2001/08/28"> 00087 // <li> 00088 // </todo> 00089 00090 00091 template <class T> class ImageConvolver 00092 { 00093 public: 00094 00095 enum ScaleTypes { 00096 00097 // None; neither autoscaling nor direct scaling 00098 NONE, 00099 00100 // Autoscale (normalize kernel to unit sum) 00101 AUTOSCALE, 00102 00103 // SCALE (apply given scale factor) 00104 SCALE, 00105 00106 // Number 00107 NTypes}; 00108 00109 // Constructor 00110 ImageConvolver (); 00111 00112 // Copy constructor. Uses reference semantics. 00113 ImageConvolver(const ImageConvolver<T> &other); 00114 00115 // Destructor 00116 ~ImageConvolver(); 00117 00118 // Assignment operator. Uses reference semantics. 00119 ImageConvolver &operator=(const ImageConvolver<T> &other); 00120 00121 // Convolve by an Image, Lattice or Array. If convolving by an image 00122 // some rudimentary coordinate checks are made and warnings optionally issued 00123 // (<src>warnOnly</src>) if things are not commensurate. 00124 // If the output image needs a mask and doesn't have one, 00125 // it will be given one if possible. The input mask is transferred to 00126 // the output. The miscInfo, imageInfo, units and logger will be copied 00127 // from the input to the output unless you indicate not 00128 // to (copyMiscellaneous). Any restoring beam is deleted from the 00129 // output image ImageInfo object. The input CoordinateSystem 00130 // is transferred to the output image. Degenerate axes are added 00131 // to the kernel if it does not have enough dimensions. If <src>autoScale</src> 00132 // is true, the kernel is normalized to have unit sum. Otherwise, 00133 // the kernel is scaled (multiplied) by the value <src>scale</src> 00134 // <group> 00135 void convolve(LogIO& os, 00136 ImageInterface<T>& imageOut, 00137 const ImageInterface<T>& imageIn, 00138 const ImageInterface<T>& kernel, 00139 const ScaleTypes scaleType, const Double scale, 00140 const Bool copyMiscellaneous, const Bool warnOnly); 00141 void convolve(LogIO& os, 00142 ImageInterface<T>& imageOut, 00143 const ImageInterface<T>& imageIn, 00144 const Lattice<T>& kernel, 00145 const ScaleTypes scaleType, 00146 const Double scale, 00147 const Bool copyMiscellaneous); 00148 void convolve(LogIO& os, 00149 ImageInterface<T>& imageOut, 00150 const ImageInterface<T>& imageIn, 00151 const Array<T>& kernel, 00152 const ScaleTypes scaleType, 00153 const Double scale, 00154 const Bool copyMiscellaneous); 00155 // </group> 00156 00157 private: 00158 00159 // Make mask for image 00160 void makeMask(ImageInterface<T>& out, LogIO& os) const; 00161 00162 // Check Coordinates of kernel and image 00163 void checkCoordinates (LogIO& os, const CoordinateSystem& cSysImage, 00164 const CoordinateSystem& cSysKernel, 00165 Bool warnOnly) const; 00166 }; 00167 00168 00169 00170 } //# NAMESPACE CASA - END 00171 00172 #ifndef CASACORE_NO_AUTO_TEMPLATES 00173 #include <imageanalysis/ImageAnalysis/ImageConvolver.tcc> 00174 #endif //# CASACORE_NO_AUTO_TEMPLATES 00175 #endif