casacore
Loading...
Searching...
No Matches
ExtendImage.h
Go to the documentation of this file.
1// # ExtendImage.h: An extension of an ImageInterface object
2// # Copyright (C) 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: casa-feedback@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#ifndef IMAGES_EXTENDIMAGE_H
27#define IMAGES_EXTENDIMAGE_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/images/Images/ImageInterface.h>
32#include <memory>
33
34namespace casacore { // # NAMESPACE CASACORE - BEGIN
35
36// # Forward Declarations
37template <class T>
38class ExtendLattice;
39
40// <summary>
41// An extension of an ImageInterface object.
42// </summary>
43//
44// <use visibility=export>
45//
46// <reviewed reviewer="" date="" tests="tExtendImage.cc">
47// </reviewed>
48//
49// <prerequisite>
50// <li> <linkto class=ImageInterface>ImageInterface</linkto>
51// <li> <linkto class=ExtendLattice>ExtendLattice</linkto>
52// </prerequisite>
53//
54// <synopsis>
55// Class ExtendImage can be used to (virtually) extend an image
56// along axes with length 1 and/or to add new axes. In this way such
57// an image can be made conformant with another image.
58// E.g. it can be used to extend the continuum channel to
59// subtract it from each channel in an image cube.
60// </synopsis>
61//
62// <example>
63// <srcblock>
64// </srcblock>
65// </example>
66//
67// <motivation>
68// Used by LEL to handle images with different dimensionalities.
69// </motivation>
70//
71// # <todo asof="1998/02/09">
72// # </todo>
73
74template <class T>
75class ExtendImage : public ImageInterface<T> {
76 public:
77 // The default constructor
79
80 // Create a ExtendImage from a Image.
81 // The coordinate system of the given image should be a subset of the
82 // new coordinate system. The same is true for the shape.
83 ExtendImage(const ImageInterface<T>& image, const IPosition& newShape,
84 const CoordinateSystem& newCsys);
85
86 // Copy constructor (reference semantics).
88
89 virtual ~ExtendImage();
90
91 // Assignment (reference semantics).
93
94 // Make a copy of the object (reference semantics).
95 // <group>
96 virtual ImageInterface<T>* cloneII() const;
97 // </group>
98
99 // Get the image type (returns name of derived class).
100 virtual String imageType() const;
101
102 // Is the ExtendImage masked?
103 // It is if its parent image is masked.
104 virtual Bool isMasked() const;
105
106 // Does the image object have a pixelmask?
107 // It does if its parent has a pixelmask.
108 virtual Bool hasPixelMask() const;
109
110 // Get access to the pixelmask in use (thus to the pixelmask of the parent).
111 // An exception is thrown if the parent does not have a pixelmask.
112 // <group>
113 virtual const Lattice<Bool>& pixelMask() const;
115 // </group>
116
117 // Get the region used (always returns 0).
118 virtual const LatticeRegion* getRegionPtr() const;
119
120 // A ExtendImage is not persistent.
121 virtual Bool isPersistent() const;
122
123 // Is the ExtendImage paged to disk?
124 virtual Bool isPaged() const;
125
126 // An ExtendImage is not writable
127 virtual Bool isWritable() const;
128
129 // Returns the shape of the ExtendImage
130 virtual IPosition shape() const;
131
132 // This function returns the recommended maximum number of pixels to
133 // include in the cursor of an iterator.
134 virtual uInt advisedMaxPixels() const;
135
136 // Function which changes the shape of the ExtendImage.
137 // Throws an exception as resizing an ExtendImage is not possible.
138 virtual void resize(const TiledShape& newShape);
139
140 // Return the name of the parent ImageInterface object.
141 virtual String name(Bool stripPath = False) const;
142
143 // Check class invariants.
144 virtual Bool ok() const;
145
146 // Get access to the attribute handler (of the parent image).
147 // If a handler keyword does not exist yet, it is created if
148 // <src>createHandler</src> is set.
149 // Otherwise the handler is empty and no groups can be created for it.
150 virtual ImageAttrHandler& attrHandler(Bool createHandler = False);
151
152 // Do the actual getting of an array of values.
153 virtual Bool doGetSlice(Array<T>& buffer, const Slicer& section);
154
155 // Putting data is not possible.
156 virtual void doPutSlice(const Array<T>& sourceBuffer, const IPosition& where,
157 const IPosition& stride);
158
159 // Get a section of the mask.
160 virtual Bool doGetMaskSlice(Array<Bool>& buffer, const Slicer& section);
161
162 // This function is used by the LatticeIterator class to generate an
163 // iterator of the correct type for this Lattice. Not recommended
164 // for general use.
165 virtual LatticeIterInterface<T>* makeIter(const LatticeNavigator& navigator, Bool useRef) const;
166
167 // Get the best cursor shape.
168 virtual IPosition doNiceCursorShape(uInt maxPixels) const;
169
170 // Handle the (un)locking and syncing, etc.
171 // <group>
172 virtual Bool lock(FileLocker::LockType, uInt nattempts);
173 virtual void unlock();
175 virtual void resync();
176 virtual void flush();
177 virtual void tempClose();
178 virtual void reopen();
179 // </group>
180
181 private:
182 // # itsImagePtr points to the parent image.
183 std::unique_ptr<ImageInterface<T>> itsImagePtr;
184 std::unique_ptr<ExtendLattice<T>> itsExtLatPtr;
185
186 // # Make members of parent class known.
187 public:
188 using ImageInterface<T>::logger;
189
190 protected:
192};
193
194} // namespace casacore
195
196#ifndef CASACORE_NO_AUTO_TEMPLATES
197#include <casacore/images/Images/ExtendImage.tcc>
198#endif // # CASACORE_NO_AUTO_TEMPLATES
199#endif
virtual Bool isWritable() const
An ExtendImage is not writable.
virtual const Lattice< Bool > & pixelMask() const
Get access to the pixelmask in use (thus to the pixelmask of the parent).
virtual LatticeIterInterface< T > * makeIter(const LatticeNavigator &navigator, Bool useRef) const
This function is used by the LatticeIterator class to generate an iterator of the correct type for th...
virtual Bool doGetSlice(Array< T > &buffer, const Slicer &section)
Do the actual getting of an array of values.
virtual void resize(const TiledShape &newShape)
Function which changes the shape of the ExtendImage.
virtual Bool ok() const
Check class invariants.
virtual void tempClose()
Temporarily close the lattice.
virtual ImageInterface< T > * cloneII() const
Make a copy of the object (reference semantics).
virtual void unlock()
virtual String name(Bool stripPath=False) const
Return the name of the parent ImageInterface object.
virtual Lattice< Bool > & pixelMask()
virtual void resync()
Resynchronize the Lattice object with the lattice file.
virtual const LatticeRegion * getRegionPtr() const
Get the region used (always returns 0).
virtual void reopen()
Explicitly reopen the temporarily closed lattice.
virtual Bool isMasked() const
Is the ExtendImage masked?
virtual void doPutSlice(const Array< T > &sourceBuffer, const IPosition &where, const IPosition &stride)
Putting data is not possible.
virtual Bool hasLock(FileLocker::LockType) const
virtual IPosition doNiceCursorShape(uInt maxPixels) const
Get the best cursor shape.
virtual Bool isPersistent() const
A ExtendImage is not persistent.
virtual ImageAttrHandler & attrHandler(Bool createHandler=False)
Get access to the attribute handler (of the parent image).
virtual String imageType() const
Get the image type (returns name of derived class).
ExtendImage()
The default constructor.
virtual Bool doGetMaskSlice(Array< Bool > &buffer, const Slicer &section)
Get a section of the mask.
ExtendImage(const ImageInterface< T > &image, const IPosition &newShape, const CoordinateSystem &newCsys)
Create a ExtendImage from a Image.
virtual IPosition shape() const
Returns the shape of the ExtendImage.
virtual Bool isPaged() const
Is the ExtendImage paged to disk?
ExtendImage(const ExtendImage< T > &other)
Copy constructor (reference semantics).
std::unique_ptr< ImageInterface< T > > itsImagePtr
virtual uInt advisedMaxPixels() const
This function returns the recommended maximum number of pixels to include in the cursor of an iterato...
virtual void flush()
Flush the data (but do not unlock).
virtual Bool hasPixelMask() const
Does the image object have a pixelmask?
ExtendImage< T > & operator=(const ExtendImage< T > &other)
Assignment (reference semantics).
std::unique_ptr< ExtendLattice< T > > itsExtLatPtr
virtual Bool lock(FileLocker::LockType, uInt nattempts)
Handle the (un)locking and syncing, etc.
LockType
Define the possible lock types.
Definition FileLocker.h:89
void setCoordsMember(const CoordinateSystem &coords)
Set the coordinate system variable.
LoggerHolder & logger()
Get access to the LoggerHolder.
String: the storage and methods of handling collections of characters.
Definition String.h:355
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
const Bool False
Definition aipstype.h:42
unsigned int uInt
Definition aipstype.h:49
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40