casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
SubImageFactory.h
Go to the documentation of this file.
00001 //# SubImage.h: A (masked) subset of an ImageInterface object
00002 //# Copyright (C) 1998,1999,2000,2001,2003
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id: SubImage.h 20739 2009-09-29 01:15:15Z Malte.Marquarding $
00027 
00028 #ifndef IMAGESANALYSIS_SUBIMAGEFACTORY_H
00029 #define IMAGESANALYSIS_SUBIMAGEFACTORY_H
00030 
00031 #include <images/Images/SubImage.h>
00032 
00033 namespace casa { //# NAMESPACE CASA - BEGIN
00034 
00035 // <summary>
00036 // Static methods for subimage creation
00037 // </summary>
00038 //
00039 // <use visibility=export>
00040 //
00041 // <reviewed reviewer="" date="" tests="tSubImageFactory.cc">
00042 // </reviewed>
00043 //
00044 // <prerequisite>
00045 //   <li> <linkto class=ImageInterface>SubImage</linkto>
00046 // </prerequisite>
00047 //
00048 // <synopsis> 
00049 // Factory methods for creating subimages
00050 // <srcblock>
00051 // </srcblock>
00052 // </example>
00053 //
00054 // <motivation>
00055 // </motivation>
00056 //
00057 // <todo asof="2013/02/24">
00058 // </todo>
00059 
00060 
00061 template <class T> class SubImageFactory {
00062 public: 
00063   // Factory method to create a SubImage from a region and a WCLELMask string.
00064   // Moved from ImageAnalysis
00065   // <src>outRegion</src> Pointer to the corresponding region. Pointer is
00066   // created internally by new(); it is the caller's responsibility to delete it.
00067   // <src>outMask</src> Pointer to corresponding mask. Pointer is created
00068   // internally via new(); it is the caller's responsibility to delete it.
00069   // <src>inImage</src> input image for which a subimage is desired.
00070   // <src>region</src> Input region record from which to make the subimage.
00071   // <src>mask</src> LEL mask description.
00072   // <src>os</src> Pointer to logger to which to log messages. If null, no logging (except exceptions).
00073   // <src>writableIfPossible</src> make the subimage writable. If input image is not writable, this
00074   // will always be False.
00075   // <src>axesSpecifier</src> Specifier for output axes.
00076   // <src>extendMask</src> If the mask has one
00077   // or more of degenerate axes whereas the corresponding axes of <src>inImage</src> are
00078   // not, extend the mask to match the shape of the input image.
00079   // <src>preserveAxesOrder</src>. Only used when dropping degenerate axes and coordinate order
00080   // and axes order are not the same. In that case, if False, the pixel/world axes order of the
00081   // returned image will be different from the input, if True it will be the same. If not
00082   // dropping degenerate axes or if coordinate order and axes order are the same in the input
00083   // image's coordinate system, the output axex order will always be preserved.
00084 
00085   static SubImage<T> createSubImage(
00086           ImageRegion*& outRegion, ImageRegion*& outMask,
00087       ImageInterface<T>& inImage, const Record& region,
00088       const String& mask, LogIO *const &os, Bool writableIfPossible,
00089       const AxesSpecifier& axesSpecifier=casa::AxesSpecifier(),
00090       Bool extendMask=False, Bool preserveAxesOrder=False
00091   );
00092 
00093   // variant on previous method where caller doesn't have to worry
00094   // about creating pointers it does not need returned.
00095   static SubImage<T> createSubImage(
00096       ImageInterface<T>& inImage, const Record& region,
00097       const String& mask, LogIO *const &os, Bool writableIfPossible,
00098       const AxesSpecifier& axesSpecifier=casa::AxesSpecifier(),
00099       Bool extendMask=False, Bool preserveAxesOrder=False
00100   );
00101 
00102   // return a PagedImage if outfile is not blank or a SubImage if it is.
00103   static ImageInterface<Float>* createImage(
00104           ImageInterface<T>& image,
00105           const String& outfile, Record& Region,
00106           const String& mask, const Bool dropDegenerateAxes,
00107           const Bool overwrite, const Bool list, const Bool extendMask
00108   );
00109 
00110   private:
00111     SubImageFactory<T> (); 
00112 };
00113 
00114 
00115 
00116 } //# NAMESPACE CASA - END
00117 
00118 #ifndef CASACORE_NO_AUTO_TEMPLATES
00119 #include <imageanalysis/ImageAnalysis/SubImageFactory.tcc>
00120 #endif //# CASACORE_NO_AUTO_TEMPLATES
00121 #endif