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