casacore
Loading...
Searching...
No Matches
RebinImage.h
Go to the documentation of this file.
1// # RebinImage.h: rebin an image
2// # Copyright (C) 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_REBINIMAGE_H
27#define IMAGES_REBINIMAGE_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/images/Images/ImageInterface.h>
32
33namespace casacore { // # NAMESPACE CASACORE - BEGIN
34
35// # Forward Declarations
36template <class T>
37class RebinLattice;
38class LogIO;
39
40// <summary>
41// Rebin an image
42// </summary>
43//
44// <use visibility=export>
45//
46// <reviewed reviewer="" date="" tests="tRebinImage.cc">
47// </reviewed>
48//
49// <prerequisite>
50// <li> <linkto class=ImageInterface>ImageInterface</linkto>
51// <li> <linkto class=RebinLattice>RebinLattice</linkto>
52// </prerequisite>
53//
54// <synopsis>
55// Class RebinImage can be used to rebin (data averaged over bin) an image
56// by integer amounts per axis.
57// </synopsis>
58//
59// <example>
60// <srcblock>
61// IPosition factors(2,2,2);
62// PagedImage<Float> imageIn(String("myImage")):
63// RebinLattice<Float> rb(imageIn, factors);
64// IPosition shapeOut = rb.shape();
65// TiledShape tShapeOut(shapeOut);
66// TempImage<Float> imageOut(tShapeOut, rb.coordinates());
67// LatticeUtilities::copyDataAndMask(os, imageOut, rb);
68// ImageUtilities::copyMiscellaneous (imageOut, imageIn);
69// </srcblock>
70// </example>
71//
72// <motivation>
73// Users like to rebin images...
74// </motivation>
75//
76// <todo asof="2004/04/07">
77// </todo>
78
79template <class T>
80class RebinImage : public ImageInterface<T> {
81 public:
82 // Default constructor (object useless)
84
85 // Constructor. The bin factors don't have to be integral. Anything left over
86 // at the end is treated as a full bin.
87 RebinImage(const ImageInterface<T>&, const IPosition& factors);
88
89 // Copy constructor (reference semantics).
91
92 virtual ~RebinImage();
93
94 // Assignment (reference semantics).
96
97 // Make a copy of the object (reference semantics).
98 // <group>
99 virtual ImageInterface<T>* cloneII() const;
100 // </group>
101
102 // Get the image type (returns name of derived class).
103 virtual String imageType() const;
104
105 // Is the RebinImage masked?
106 // It is if its parent image is masked.
107 virtual Bool isMasked() const;
108
109 // Does the image object have a pixelmask?
110 // It does if its parent has a pixelmask.
111 virtual Bool hasPixelMask() const;
112
113 // Get access to the pixelmask in use (thus to the pixelmask of the parent).
114 // An exception is thrown if the parent does not have a pixelmask.
115 // <group>
116 virtual const Lattice<Bool>& pixelMask() const;
118 // </group>
119
120 // Get the region used (always returns 0).
121 virtual const LatticeRegion* getRegionPtr() const;
122
123 // A RebinImage is not persistent.
124 virtual Bool isPersistent() const;
125
126 // Is the RebinImage paged to disk?
127 virtual Bool isPaged() const;
128
129 // An RebinImage is not writable
130 virtual Bool isWritable() const;
131
132 // Returns the shape of the RebinImage
133 virtual IPosition shape() const;
134
135 // This function returns the recommended maximum number of pixels to
136 // include in the cursor of an iterator.
137 virtual uInt advisedMaxPixels() const;
138
139 // Function which changes the shape of the RebinImage.
140 // Throws an exception as resizing an RebinImage is not possible.
141 virtual void resize(const TiledShape& newShape);
142
143 // Return the name of the parent ImageInterface object.
144 virtual String name(Bool stripPath = False) const;
145
146 // Check class invariants.
147 virtual Bool ok() const;
148
149 // Get access to the attribute handler (of the parent image).
150 // If a handler keyword does not exist yet, it is created if
151 // <src>createHandler</src> is set.
152 // Otherwise the handler is empty and no groups can be created for it.
153 virtual ImageAttrHandler& attrHandler(Bool createHandler = False);
154
155 // Do the actual getting of an array of values.
156 // Non-unit strides are not yet supported.
157 virtual Bool doGetSlice(Array<T>& buffer, const Slicer& section);
158
159 // Putting data is not possible as the lattice is not writable.
160 virtual void doPutSlice(const Array<T>& sourceBuffer, const IPosition& where,
161 const IPosition& stride);
162
163 // Get a section of the mask.
164 // Non-unit strides are not yet supported.
165 virtual Bool doGetMaskSlice(Array<Bool>& buffer, const Slicer& section);
166
167 // This function is used by the LatticeIterator class to generate an
168 // iterator of the correct type for this Lattice. Not recommended
169 // for general use.
170 virtual LatticeIterInterface<T>* makeIter(const LatticeNavigator& navigator, Bool useRef) const;
171
172 // Get the best cursor shape.
173 virtual IPosition doNiceCursorShape(uInt maxPixels) const;
174
175 // Handle the (un)locking and syncing, etc.
176 // <group>
177 virtual Bool lock(FileLocker::LockType, uInt nattempts);
178 virtual void unlock();
180 virtual void resync();
181 virtual void flush();
182 virtual void tempClose();
183 virtual void reopen();
184 // </group>
185
186 private:
187 // # itsImagePtr points to the parent image.
190
191 // # Make members of parent class known.
192 public:
193 using ImageInterface<T>::logger;
194
195 protected:
197};
198
199} // namespace casacore
200
201#ifndef CASACORE_NO_AUTO_TEMPLATES
202#include <casacore/images/Images/RebinImage.tcc>
203#endif // # CASACORE_NO_AUTO_TEMPLATES
204#endif
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.
virtual void reopen()
Explicitly reopen the temporarily closed lattice.
virtual void resync()
Resynchronize the Lattice object with the lattice file.
virtual const Lattice< Bool > & pixelMask() const
Get access to the pixelmask in use (thus to the pixelmask of the parent).
virtual ImageAttrHandler & attrHandler(Bool createHandler=False)
Get access to the attribute handler (of the parent image).
RebinLattice< T > * itsRebinPtr
Definition RebinImage.h:189
virtual Lattice< Bool > & pixelMask()
virtual IPosition doNiceCursorShape(uInt maxPixels) const
Get the best cursor shape.
virtual const LatticeRegion * getRegionPtr() const
Get the region used (always returns 0).
virtual void flush()
Flush the data (but do not unlock).
virtual Bool hasLock(FileLocker::LockType) const
virtual void doPutSlice(const Array< T > &sourceBuffer, const IPosition &where, const IPosition &stride)
Putting data is not possible as the lattice is not writable.
virtual void unlock()
virtual Bool isMasked() const
Is the RebinImage masked?
virtual Bool lock(FileLocker::LockType, uInt nattempts)
Handle the (un)locking and syncing, etc.
virtual void tempClose()
Temporarily close the lattice.
virtual uInt advisedMaxPixels() const
This function returns the recommended maximum number of pixels to include in the cursor of an iterato...
virtual Bool hasPixelMask() const
Does the image object have a pixelmask?
virtual ImageInterface< T > * cloneII() const
Make a copy of the object (reference semantics).
virtual Bool isWritable() const
An RebinImage is not writable.
virtual Bool doGetSlice(Array< T > &buffer, const Slicer &section)
Do the actual getting of an array of values.
RebinImage< T > & operator=(const RebinImage< T > &other)
Assignment (reference semantics).
virtual String imageType() const
Get the image type (returns name of derived class).
RebinImage(const ImageInterface< T > &, const IPosition &factors)
Constructor.
RebinImage()
Default constructor (object useless).
virtual Bool ok() const
Check class invariants.
virtual void resize(const TiledShape &newShape)
Function which changes the shape of the RebinImage.
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 String name(Bool stripPath=False) const
Return the name of the parent ImageInterface object.
virtual Bool isPersistent() const
A RebinImage is not persistent.
virtual IPosition shape() const
Returns the shape of the RebinImage.
ImageInterface< T > * itsImagePtr
Definition RebinImage.h:188
virtual Bool isPaged() const
Is the RebinImage paged to disk?
RebinImage(const RebinImage< T > &other)
Copy constructor (reference semantics).
virtual Bool doGetMaskSlice(Array< Bool > &buffer, const Slicer &section)
Get a section of the mask.
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