casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ImageConvolver.h
Go to the documentation of this file.
1 //# ImageConvolver.h: convolution of an image by array
2 //# Copyright (C) 1996,1997,1998,1999,2000,2001,2003
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id: ImageConvolver.h 20229 2008-01-29 15:19:06Z gervandiepen $
27 
28 #ifndef IMAGES_IMAGECONVOLVER_H
29 #define IMAGES_IMAGECONVOLVER_H
30 
31 
32 //# Includes
33 #include <casa/aips.h>
34 #include <casa/Logging/LogIO.h>
35 #include <casa/Arrays/Array.h>
36 
37 namespace casacore{
38 
39 template <class T> class ImageInterface;
40 template <class T> class Lattice;
41 class CoordinateSystem;
42 class String;
43 }
44 
45 namespace casa { //# NAMESPACE CASA - BEGIN
46 
47 //# Forward Declarations
48 
49 
50 
51 // <summary>
52 // This class does convolution of an image by an casacore::Array or Lattice
53 // </summary>
54 
55 // <use visibility=export>
56 
57 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
58 // </reviewed>
59 
60 // <prerequisite>
61 // <li> <linkto class="casacore::ImageInterface">casacore::ImageInterface</linkto>
62 // <li> <linkto class="casacore::LatticeConvolver">casacore::LatticeConvolver</linkto>
63 // </prerequisite>
64 
65 // <etymology>
66 // This class handles convolution of images by an casacore::Array or Lattice
67 // </etymology>
68 
69 // <synopsis>
70 // This class convolves an image by a specified kernel (casacore::Array or
71 // casacore::Lattice). If the kernel does not have enough dimensions, degenerate
72 // ones are added.The class object has no state. The functions could be static.
73 // The convolution is done via FFT. Thus input pixels which
74 // are masked are set to 0 before the convolution. The mask
75 // is transferred to the output image. No additional scaling
76 // of the output image values is done.
77 //
78 
79 // </synopsis>
80 
81 // <example>
82 // <srcBlock>
83 // </srcBlock>
84 // </example>
85 
86 // <motivation>
87 // Convolution is a standard image processing requirement.
88 // </motivation>
89 
90 // <todo asof="2001/08/28">
91 // <li>
92 // </todo>
93 
94 
95 template <class T> class ImageConvolver
96 {
97 public:
98 
99 enum ScaleTypes {
100 
101 // None; neither autoscaling nor direct scaling
103 
104 // Autoscale (normalize kernel to unit sum)
106 
107 // SCALE (apply given scale factor)
109 
110 // Number
112 
113 // Constructor
114  ImageConvolver ();
115 
116 // Copy constructor. Uses reference semantics.
117  ImageConvolver(const ImageConvolver<T> &other);
118 
119 // Destructor
120  ~ImageConvolver();
121 
122 // Assignment operator. Uses reference semantics.
124 
125 // Convolve by an Image, casacore::Lattice or Array. If convolving by an image
126 // some rudimentary coordinate checks are made and warnings optionally issued
127 // (<src>warnOnly</src>) if things are not commensurate.
128 // If the output image needs a mask and doesn't have one,
129 // it will be given one if possible. The input mask is transferred to
130 // the output. The miscInfo, imageInfo, units and logger will be copied
131 // from the input to the output unless you indicate not
132 // to (copyMiscellaneous). Any restoring beam is deleted from the
133 // output image casacore::ImageInfo object. The input CoordinateSystem
134 // is transferred to the output image. Degenerate axes are added
135 // to the kernel if it does not have enough dimensions. If <src>autoScale</src>
136 // is true, the kernel is normalized to have unit sum. Otherwise,
137 // the kernel is scaled (multiplied) by the value <src>scale</src>
138 // <group>
139  void convolve(casacore::LogIO& os,
140  casacore::ImageInterface<T>& imageOut,
141  const casacore::ImageInterface<T>& imageIn,
142  const casacore::ImageInterface<T>& kernel,
143  const ScaleTypes scaleType, const casacore::Double scale,
144  const casacore::Bool copyMiscellaneous, const casacore::Bool warnOnly);
145  void convolve(casacore::LogIO& os,
146  casacore::ImageInterface<T>& imageOut,
147  const casacore::ImageInterface<T>& imageIn,
148  const casacore::Lattice<T>& kernel,
149  const ScaleTypes scaleType,
150  const casacore::Double scale,
151  const casacore::Bool copyMiscellaneous);
152  void convolve(casacore::LogIO& os,
153  casacore::ImageInterface<T>& imageOut,
154  const casacore::ImageInterface<T>& imageIn,
155  const casacore::Array<T>& kernel,
156  const ScaleTypes scaleType,
157  const casacore::Double scale,
158  const casacore::Bool copyMiscellaneous);
159 // </group>
160 
161 private:
162 
163 // Make mask for image
165 
166 // Check Coordinates of kernel and image
167  void checkCoordinates (casacore::LogIO& os, const casacore::CoordinateSystem& cSysImage,
168  const casacore::CoordinateSystem& cSysKernel,
169  casacore::Bool warnOnly) const;
170 };
171 
172 
173 
174 } //# NAMESPACE CASA - END
175 
176 #ifndef CASACORE_NO_AUTO_TEMPLATES
177 #include <imageanalysis/ImageAnalysis/ImageConvolver.tcc>
178 #endif //# CASACORE_NO_AUTO_TEMPLATES
179 #endif
void makeMask(casacore::ImageInterface< T > &out, casacore::LogIO &os) const
Make mask for image.
Autoscale (normalize kernel to unit sum)
None; neither autoscaling nor direct scaling.
SCALE (apply given scale factor)
ostream-like interface to creating log messages.
Definition: LogIO.h:167
A templated, abstract base class for array-like objects.
~ImageConvolver()
Destructor.
A base class for astronomical images.
double Double
Definition: aipstype.h:55
void convolve(casacore::LogIO &os, casacore::ImageInterface< T > &imageOut, const casacore::ImageInterface< T > &imageIn, const casacore::ImageInterface< T > &kernel, const ScaleTypes scaleType, const casacore::Double scale, const casacore::Bool copyMiscellaneous, const casacore::Bool warnOnly)
Convolve by an Image, casacore::Lattice or Array.
void checkCoordinates(casacore::LogIO &os, const casacore::CoordinateSystem &cSysImage, const casacore::CoordinateSystem &cSysKernel, casacore::Bool warnOnly) const
Check Coordinates of kernel and image.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
template &lt;class T, class U&gt; class vector;
Definition: MSFlagger.h:37
ImageConvolver & operator=(const ImageConvolver< T > &other)
Assignment operator.
ImageConvolver()
Constructor.
Interconvert pixel and world coordinates.
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42
This class does convolution of an image by an casacore::Array or Lattice.