casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SepImageConvolver.h
Go to the documentation of this file.
1 //# SepImageConvolver.h: separable convolution of an image
2 //# Copyright (C) 1996,1997,1998,1999,2000,2001,2002,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: SepImageConvolver.h 20229 2008-01-29 15:19:06Z gervandiepen $
27 
28 #ifndef IMAGES_SEPIMAGECONVOLVER_H
29 #define IMAGES_SEPIMAGECONVOLVER_H
30 
31 
32 //# Includes
33 #include <casa/aips.h>
34 #include <casa/Logging/LogIO.h>
35 #include <casa/Arrays/Vector.h>
36 #include <casa/Containers/Block.h>
39 
40 namespace casacore{
41 
42 template <class T> class Quantum;
43 class String;
44 }
45 
46 namespace casa { //# NAMESPACE CASA - BEGIN
47 
48 //# Forward Declarations
49 
50 
51 
52 // <summary>
53 // This class does separable convolution of an image
54 // </summary>
55 
56 // <use visibility=export>
57 
58 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
59 // </reviewed>
60 
61 // <prerequisite>
62 // <li> <linkto class="casacore::ImageInterface">casacore::ImageInterface</linkto>
63 // <li> <linkto class="casacore::Convolver">casacore::Convolver</linkto>
64 // </prerequisite>
65 
66 // <etymology>
67 // This class handles convolution of images by separable kernels.
68 // </etymology>
69 
70 // <synopsis>
71 // Convolution kernels can be separable or not. For example,
72 // convolution of an image by a 2-D gaussian when the position angle
73 // of the Gaussian is along one of the axes is separable. If the
74 // position angle is otherwise, it is not separable. When the
75 // kernel is separable, an N-dimensional specification of the
76 // convolution kernel is straightforward.
77 //
78 // Although this class is templated, it will only work
79 // for casacore::Float and casacore::Double types.
80 // </synopsis>
81 
82 // <example>
83 // <srcBlock>
84 // </srcBlock>
85 // </example>
86 
87 // <motivation>
88 // Separable and non-separable convolution are standard requirements.
89 // </motivation>
90 
91 // <todo asof="1999/03/31">
92 // <li>
93 // </todo>
94 
95 
96 template <class T> class SepImageConvolver
97 {
98 public:
99 
100 
101  // Constructor
103 
104  // Copy constructor. Uses reference semantics.
106 
107  // Destructor
109 
110  // Assignment operator. Uses reference semantics.
112 
113  // Set convolution kernel vector. The specified axis is convolved
114  // by the given kernel.
115  void setKernel(casacore::uInt axis, const casacore::Vector<T>& kernel);
116 
117  // Set convolution kernel. The specified axis is convolved
118  // by the given kernel. If autoScale is true then kernel volume is unity,
119  // else kernel peak is 1 * scale. If useImageShapeExactly is true, the kernel
120  // will be the shape of the axis, else it will be big enough
121  // to accomodate the kernel width (e.g. +/- 5sigma for Gaussian)
122  // <group>
123  void setKernel(
125  const casacore::Quantum<casacore::Double>& width, casacore::Bool autoScale,
126  casacore::Bool useImageShapeExactly=true, casacore::Double scale=1.0
127  );
128 
129  void setKernel(
131  casacore::Double width, casacore::Bool autoScale,
132  casacore::Bool useImageShapeExactly=true, casacore::Double scale=1.0
133  );
134  // </group>
135 
136  // Get the convolution kernel for the specified axis
138 
139  // Get the convolution kernel shape for the specified axis
141 
142  // Perform the convolution either outputting to a new image
143  // or in-situ. The error checking for the
144  // convolution parameters is done when you call this
145  // function. If outputting a new image, and it needs a mask and doesn't have one,
146  // the it will be given one if possible and the input
147  // mask will be transferred to the output. Masked pixels
148  // are zeroed before convolving
149  void convolve(casacore::ImageInterface<T>& imageOut);
150 
151 
152 private:
158 
159  void _checkAxis(casacore::uInt axis);
160  void _zero();
161  void _smoothProfiles(
163  const casacore::Vector<T>& psf
164  );
165 };
166 
167 } //# NAMESPACE CASA - END
168 
169 #ifndef CASACORE_NO_AUTO_TEMPLATES
170 #include <imageanalysis/ImageAnalysis/SepImageConvolver.tcc>
171 #endif //# CASACORE_NO_AUTO_TEMPLATES
172 #endif
SepImageConvolver(const casacore::ImageInterface< T > &image, casacore::LogIO &os, casacore::Bool showProgress)
Constructor.
A 1-D Specialization of the Array class.
int Int
Definition: aipstype.h:50
SepImageConvolver & operator=(const SepImageConvolver< T > &other)
Assignment operator.
~SepImageConvolver()
Destructor.
void _checkAxis(casacore::uInt axis)
casacore::Vector< casacore::uInt > itsAxes
ostream-like interface to creating log messages.
Definition: LogIO.h:167
casacore::Vector< T > getKernel(casacore::uInt axis)
Get the convolution kernel for the specified axis.
This class does separable convolution of an image.
void convolve(casacore::ImageInterface< T > &imageOut)
Perform the convolution either outputting to a new image or in-situ.
void _smoothProfiles(casacore::ImageInterface< T > &in, const casacore::Int &axis, const casacore::Vector< T > &psf)
casacore::uInt getKernelShape(casacore::uInt axis)
Get the convolution kernel shape for the specified axis.
A base class for astronomical images.
double Double
Definition: aipstype.h:55
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
A drop-in replacement for Block&lt;T*&gt;.
Definition: WProjectFT.h:54
casacore::PtrBlock< casacore::Vector< T > * > itsVectorKernels
void setKernel(casacore::uInt axis, const casacore::Vector< T > &kernel)
Set convolution kernel vector.
casacore::Bool itsShowProgress
casacore::ImageInterface< T > * itsImagePtr
unsigned int uInt
Definition: aipstype.h:51
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42