Line data Source code
1 : //# Copyright (C) 1998,1999,2000,2001,2003
2 : //# Associated Universities, Inc. Washington DC, USA.
3 : //#
4 : //# This program is free software; you can redistribute it and/or modify it
5 : //# under the terms of the GNU General Public License as published by the Free
6 : //# Software Foundation; either version 2 of the License, or (at your option)
7 : //# any later version.
8 : //#
9 : //# This program is distributed in the hope that it will be useful, but WITHOUT
10 : //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 : //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 : //# more details.
13 : //#
14 : //# You should have received a copy of the GNU General Public License along
15 : //# with this program; if not, write to the Free Software Foundation, Inc.,
16 : //# 675 Massachusetts Ave, Cambridge, MA 02139, USA.
17 : //#
18 : //# Correspondence concerning AIPS++ should be addressed as follows:
19 : //# Internet email: casa-feedback@nrao.edu.
20 : //# Postal address: AIPS++ Project Office
21 : //# National Radio Astronomy Observatory
22 : //# 520 Edgemont Road
23 : //# Charlottesville, VA 22903-2475 USA
24 : //#
25 :
26 : #ifndef IMAGEANALYSIS_IMAGEREGRIDDER_H
27 : #define IMAGEANALYSIS_IMAGEREGRIDDER_H
28 :
29 : #include <imageanalysis/ImageAnalysis/ImageRegridderBase.h>
30 :
31 : #include <casacore/casa/namespace.h>
32 :
33 : namespace casacore{
34 :
35 : template <class T> class SubImage;
36 : template <class T> class TempImage;
37 : }
38 :
39 : namespace casa {
40 :
41 :
42 : template<class T> class ImageRegridder : public ImageRegridderBase<T> {
43 : // <summary>
44 : // Top level interface which regrids an image to a specified coordinate
45 : // system
46 : // </summary>
47 :
48 : // <reviewed reviewer="" date="" tests="" demos="">
49 : // </reviewed>
50 :
51 : // <prerequisite>
52 : // </prerequisite>
53 :
54 : // <etymology>
55 : // Regrids image.
56 : // </etymology>
57 :
58 : // <synopsis>
59 : // High level interface for regridding an image. Note that in the case of a
60 : // complex-valued image, the image is first divided into its composite real
61 : // and imaginary parts, and these parts are regridded independently. The
62 : // resulting regridded images are combined to form the final regridded
63 : // complex-valued image.
64 : // </synopsis>
65 :
66 : public:
67 :
68 : ImageRegridder() = delete;
69 :
70 : // if <src>outname</src> is empty, no image will be written
71 : // if <src>overwrite</src> is true, if image already exists it will be
72 : // removed if <src>overwrite</src> is false, if image already exists
73 : // exception will be thrown
74 : // <group>
75 :
76 : ImageRegridder(
77 : const SPCIIT image, const casacore::Record *const regionRec,
78 : const casacore::String& maskInp, const casacore::String& outname,
79 : casacore::Bool overwrite, const casacore::CoordinateSystem& csysTo,
80 : const casacore::IPosition& axes, const casacore::IPosition& shape
81 : );
82 :
83 : // FIXME Add support to allow image and templateIm to be of different data
84 : // types
85 : ImageRegridder(
86 : const SPCIIT image, const casacore::String& outname,
87 : const SPCIIT templateIm,
88 : const casacore::IPosition& axes=casacore::IPosition(),
89 : const casacore::Record *const regionRec=0,
90 : const casacore::String& maskInp="", casacore::Bool overwrite=false,
91 : const casacore::IPosition& shape=casacore::IPosition()
92 : );
93 : // </group>
94 :
95 : // destructor
96 : ~ImageRegridder();
97 :
98 : // perform the regrid.
99 : SPIIT regrid() const;
100 :
101 0 : inline casacore::String getClass() const { return _class; }
102 :
103 : void setDebug(casacore::Int debug) { _debug = debug; }
104 :
105 : private:
106 : mutable SPIIT _subimage;
107 : casacore::Int _debug;
108 : static const casacore::String _class;
109 :
110 : SPIIT _regrid() const;
111 :
112 : SPIIT _regridByVelocity() const;
113 :
114 : casacore::Bool _doImagesOverlap(SPCIIT image0, SPCIIT image1) const;
115 :
116 : static casacore::Vector<std::pair<casacore::Double, casacore::Double> >
117 : _getDirectionCorners(
118 : const casacore::DirectionCoordinate& dc,
119 : const casacore::IPosition& directionShape
120 : );
121 :
122 : void _checkOutputShape(
123 : const casacore::SubImage<T>& subImage,
124 : const std::set<casacore::Coordinate::Type>& coordsToRegrid
125 : ) const;
126 :
127 : SPIIT _decimateStokes(SPIIT workIm) const;
128 :
129 : static casacore::Bool _doRectanglesIntersect(
130 : const casacore::Vector<
131 : std::pair<casacore::Double, casacore::Double>
132 : >& corners0,
133 : const casacore::Vector<
134 : std::pair<casacore::Double, casacore::Double>
135 : >& corners1
136 : );
137 :
138 : };
139 : }
140 :
141 : #ifndef CASACORE_NO_AUTO_TEMPLATES
142 : #include <imageanalysis/ImageAnalysis/ImageRegridder.tcc>
143 : #endif
144 :
145 : #endif
|