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
30//# Includes
31#include <casacore/casa/aips.h>
32#include <casacore/images/Images/ImageInterface.h>
33
34namespace casacore { //# NAMESPACE CASACORE - BEGIN
35
36//# Forward Declarations
37template <class T> class 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
79
80template <class T> class RebinImage: public ImageInterface<T>
81{
82public:
83
84 // Default constructor (object useless)
86
87 // Constructor. The bin factors don't have to be integral. Anything left over
88 // at the end is treated as a full bin.
89 RebinImage (const ImageInterface<T>&, const IPosition& factors);
90
91 // Copy constructor (reference semantics).
92 RebinImage (const RebinImage<T>& other);
93
94 virtual ~RebinImage();
95
96 // Assignment (reference semantics).
98
99 // Make a copy of the object (reference semantics).
100 // <group>
101 virtual ImageInterface<T>* cloneII() const;
102 // </group>
103
104 // Get the image type (returns name of derived class).
105 virtual String imageType() const;
106
107 // Is the RebinImage masked?
108 // It is if its parent image is masked.
109 virtual Bool isMasked() const;
110
111 // Does the image object have a pixelmask?
112 // It does if its parent has a pixelmask.
113 virtual Bool hasPixelMask() const;
114
115 // Get access to the pixelmask in use (thus to the pixelmask of the parent).
116 // An exception is thrown if the parent does not have a pixelmask.
117 // <group>
118 virtual const Lattice<Bool>& pixelMask() const;
120 // </group>
121
122 // Get the region used (always returns 0).
123 virtual const LatticeRegion* getRegionPtr() const;
124
125 // A RebinImage is not persistent.
126 virtual Bool isPersistent() const;
127
128 // Is the RebinImage paged to disk?
129 virtual Bool isPaged() const;
130
131 // An RebinImage is not writable
132 virtual Bool isWritable() const;
133
134 // Returns the shape of the RebinImage
135 virtual IPosition shape() const;
136
137 // This function returns the recommended maximum number of pixels to
138 // include in the cursor of an iterator.
139 virtual uInt advisedMaxPixels() const;
140
141 // Function which changes the shape of the RebinImage.
142 // Throws an exception as resizing an RebinImage is not possible.
143 virtual void resize(const TiledShape& newShape);
144
145 // Return the name of the parent ImageInterface object.
146 virtual String name (Bool stripPath=False) const;
147
148 // Check class invariants.
149 virtual Bool ok() const;
150
151 // Get access to the attribute handler (of the parent image).
152 // If a handler keyword does not exist yet, it is created if
153 // <src>createHandler</src> is set.
154 // Otherwise the handler is empty and no groups can be created for it.
155 virtual ImageAttrHandler& attrHandler (Bool createHandler=False);
156
157 // Do the actual getting of an array of values.
158 // Non-unit strides are not yet supported.
159 virtual Bool doGetSlice (Array<T>& buffer, const Slicer& section);
160
161 // Putting data is not possible as the lattice is not writable.
162 virtual void doPutSlice (const Array<T>& sourceBuffer,
163 const IPosition& where,
164 const IPosition& stride);
165
166 // Get a section of the mask.
167 // Non-unit strides are not yet supported.
168 virtual Bool doGetMaskSlice (Array<Bool>& buffer, const Slicer& section);
169
170 // This function is used by the LatticeIterator class to generate an
171 // iterator of the correct type for this Lattice. Not recommended
172 // for general use.
174 (const LatticeNavigator& navigator,
175 Bool useRef) const;
176
177 // Get the best cursor shape.
178 virtual IPosition doNiceCursorShape (uInt maxPixels) const;
179
180 // Handle the (un)locking and syncing, etc.
181 // <group>
182 virtual Bool lock (FileLocker::LockType, uInt nattempts);
183 virtual void unlock();
185 virtual void resync();
186 virtual void flush();
187 virtual void tempClose();
188 virtual void reopen();
189 // </group>
190
191private:
192 //# itsImagePtr points to the parent image.
195
196 //# Make members of parent class known.
197public:
198 using ImageInterface<T>::logger;
199protected:
201};
202
203
204
205} //# NAMESPACE CASACORE - END
206
207#ifndef CASACORE_NO_AUTO_TEMPLATES
208#include <casacore/images/Images/RebinImage.tcc>
209#endif //# CASACORE_NO_AUTO_TEMPLATES
210#endif
LockType
Define the possible lock types.
Definition FileLocker.h:93
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:194
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? It is if its parent image is 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? It does if its parent has 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:193
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:223
this file contains all the compiler specific defines
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