A base class for astronomical images. More...
#include <ImageInterface.h>
Public Member Functions | |
ImageInterface () | |
ImageInterface (const RegionHandler ®ionHandler) | |
Construct for a specific region handler object. | |
ImageInterface (const ImageInterface &other) | |
Copy constructor (copy semantics). | |
virtual | ~ImageInterface () |
virtual MaskedLattice< T > * | cloneML () const |
Make a copy of the derived object (reference semantics). | |
virtual ImageInterface< T > * | cloneII () const =0 |
virtual String | imageType () const =0 |
Get the image type (returns name of derived class). | |
virtual void | resize (const TiledShape &newShape)=0 |
Function which changes the shape of the image (N.B. | |
virtual Bool | setUnits (const Unit &newUnits) |
Function which get and set the units associated with the image pixels (i.e. | |
virtual const Unit & | units () const |
virtual String | name (Bool stripPath=False) const =0 |
Return the name of the current ImageInterface object. | |
virtual Bool | setCoordinateInfo (const CoordinateSystem &coords) |
Functions to set or replace the coordinate information in the Image Returns False on failure, e.g. | |
const CoordinateSystem & | coordinates () const |
virtual LELCoordinates | lelCoordinates () const |
Function to get a LELCoordinate object containing the coordinates. | |
LoggerHolder & | logger () |
Get access to the LoggerHolder. | |
const LoggerHolder & | logger () const |
LogIO & | logSink () |
Allow messages to be logged to this ImageInterface. | |
const LogIO & | logSink () const |
void | appendLog (const LoggerHolder &other) |
Add the messages from the other image logger to this one. | |
const TableRecord & | miscInfo () const |
Often we have miscellaneous information we want to attach to an image. | |
virtual Bool | setMiscInfo (const RecordInterface &newInfo) |
const ImageInfo & | imageInfo () const |
The ImageInfo object contains some miscellaneous information about the image which unlike that stored in MiscInfo, has a standard list of things, such as the restoring beam. | |
virtual Bool | setImageInfo (const ImageInfo &info) |
virtual ImageAttrHandler & | attrHandler (Bool createHandler=False) |
Get access to the attribute handler. | |
ImageAttrHandler & | roAttrHandler () const |
Bool | canDefineRegion () const |
Can the image handle region definition? | |
virtual ImageRegion | makeMask (const String &name, Bool defineAsRegion=True, Bool setAsDefaultMask=True, Bool initialize=False, Bool value=True) |
Make a mask which is suitable for the type of image. | |
virtual void | defineRegion (const String &name, const ImageRegion ®ion, RegionHandler::GroupType, Bool overwrite=False) |
Define a region/mask belonging to the image. | |
virtual Bool | hasRegion (const String ®ionName, RegionHandler::GroupType=RegionHandler::Any) const |
Does the image have a region with the given name? | |
virtual ImageRegion * | getImageRegionPtr (const String &name, RegionHandler::GroupType=RegionHandler::Any, Bool throwIfUnknown=True) const |
Get a region/mask belonging to the image from the given group (which can be Any). | |
virtual void | renameRegion (const String &newName, const String &oldName, RegionHandler::GroupType=RegionHandler::Any, Bool overwrite=False) |
Rename a region. | |
virtual void | removeRegion (const String &name, RegionHandler::GroupType=RegionHandler::Any, Bool throwIfUnknown=True) |
Remove a region/mask belonging to the image from the given group (which can be Any). | |
virtual Vector< String > | regionNames (RegionHandler::GroupType=RegionHandler::Any) const |
Get the names of all regions/masks. | |
virtual void | useMask (MaskSpecifier=MaskSpecifier()) |
Use the mask as specified. | |
virtual void | setDefaultMask (const String ®ionName) |
Set the default pixelmask to the mask with the given name (which has to exist in the "masks" group). | |
virtual String | getDefaultMask () const |
Get the name of the default pixelmask. | |
ImageRegion | getRegion (const String ®ionName, RegionHandler::GroupType=RegionHandler::Any) const |
Get a region belonging to the image. | |
String | makeUniqueRegionName (const String &rootName, uInt startNumber=1) const |
Make a unique region name from the given root name, thus make it such that the name is not already in use for a region or mask. | |
virtual Bool | ok () const =0 |
Check class invariants. | |
Bool | toRecord (String &error, RecordInterface &outRec) |
Save and restore an ImageInterface object to or from a state Record. | |
Bool | fromRecord (String &error, const RecordInterface &inRec) |
Protected Member Functions | |
ImageInterface & | operator= (const ImageInterface &other) |
Assignment (copy semantics) is only useful for derived classes. | |
Bool | restoreImageInfo (const RecordInterface &rec) |
Restore the image info from the record. | |
void | setLogMember (const LoggerHolder &logger) |
Set the image logger variable. | |
void | setImageInfoMember (const ImageInfo &imageInfo) |
Set the image info variable. | |
void | setCoordsMember (const CoordinateSystem &coords) |
Set the coordinate system variable. | |
void | setUnitMember (const Unit &unit) |
Set the unit variable. | |
void | setMiscInfoMember (const RecordInterface &rec) |
Set the miscinfo variable. | |
RegionHandler * | getRegionHandler () |
Get access to the region handler. | |
ImageInfo & | rwImageInfo () |
Get non-const access to the ImageInfo. | |
Private Attributes | |
CoordinateSystem | coords_p |
It is the job of the derived class to make these variables valid. | |
LoggerHolder | log_p |
ImageInfo | imageInfo_p |
Unit | unit_p |
TableRecord | miscInfo_p |
RegionHandler * | regHandPtr_p |
The region handling object. | |
ImageAttrHandler | itsBaseAttrHandler |
The attribute handling object. |
A base class for astronomical images.
Public interface
The ImageInterface class name is derived from its role as the cookie cutter Interface base class for Images.
The ImageInterface class is an abstract base class. All Image classes should derive from this class to ensure functions which operate on Images will work for all Image derivations.
An Image is currently defined as an Array of pixels, a Boolean mask, defining which pixels are valid and coordinates to define the reference frame. The only concrete class currently derived from this Interface is PagedImage, which allows the image to be stored on disk, and only reads specified portions of the image into memory.
As this is an abstract base class it is not possible to construct an instance of this object. It can however be used as a function argument.
eg 1. (used in dImageInterface.cc)
Float sumPixels(const ImageInterface<Float>& image){ uInt rowLength = image.shape()(0); IPosition rowShape(image.ndim()); rowShape = 1; rowShape(0) = rowLength; Float sumPix = 0; RO_LatticeIterator<Float> iter(image, rowShape); while(!iter.atEnd()){ sumPix += sum(iter.vectorCursor()); iter++; } return sumPix; }
The main purpose of this class is for programming objects, the following example is of how one would derive from ImageInterface:
eg 2.
template <class T> class myNewImage : public ImageInterface<T> { public: // default constructor myNewImage(); // argumented constructor myNewImage(...); // destructor ~myNewImage // the shape function is forced upon us by the Lattice base class IPosition shape() const; // doGetSlice is another function required of all Lattice objects. Bool doGetSlice(<Array<T>& buffer, const Slicer& section); // etc..\. private: // put the actual map data down here. // etc..\. };
The use of abstract base classes to guide inheritance seemed appropriate for Images to ensure that CoordinateSystems and masking get handled uniformly.
Definition at line 146 of file ImageInterface.h.
casacore::ImageInterface< T >::ImageInterface | ( | ) |
casacore::ImageInterface< T >::ImageInterface | ( | const RegionHandler & | regionHandler | ) |
Construct for a specific region handler object.
casacore::ImageInterface< T >::ImageInterface | ( | const ImageInterface< T > & | other | ) |
Copy constructor (copy semantics).
virtual casacore::ImageInterface< T >::~ImageInterface | ( | ) | [virtual] |
void casacore::ImageInterface< T >::appendLog | ( | const LoggerHolder & | other | ) | [inline] |
Add the messages from the other image logger to this one.
Definition at line 219 of file ImageInterface.h.
virtual ImageAttrHandler& casacore::ImageInterface< T >::attrHandler | ( | Bool | createHandler = False |
) | [virtual] |
Get access to the attribute handler.
By default an empty handler is returned where no groups can be added to.
Reimplemented in casacore::CurvedImage2D< T >, casacore::ExtendImage< T >, casacore::HDF5Image< T >, casacore::PagedImage< T >, casacore::RebinImage< T >, and casacore::SubImage< T >.
Referenced by casacore::ImageInterface< Complex >::roAttrHandler().
Bool casacore::ImageInterface< T >::canDefineRegion | ( | ) | const [inline] |
Can the image handle region definition?
Definition at line 254 of file ImageInterface.h.
virtual ImageInterface<T>* casacore::ImageInterface< T >::cloneII | ( | ) | const [pure virtual] |
Implemented in casacore::CurvedImage2D< T >, casacore::ExtendImage< T >, casacore::FITSErrorImage, casacore::FITSImage, casacore::FITSQualityImage, casacore::HDF5Image< T >, casacore::ImageConcat< T >, casacore::ImageExpr< T >, casacore::MIRIADImage, casacore::PagedImage< T >, casacore::RebinImage< T >, casacore::SubImage< T >, casacore::TempImage< T >, and casacore::ImageExpr< Bool >.
virtual MaskedLattice<T>* casacore::ImageInterface< T >::cloneML | ( | ) | const [virtual] |
Make a copy of the derived object (reference semantics).
Implements casacore::MaskedLattice< T >.
const CoordinateSystem& casacore::ImageInterface< T >::coordinates | ( | ) | const [inline] |
Definition at line 195 of file ImageInterface.h.
virtual void casacore::ImageInterface< T >::defineRegion | ( | const String & | name, | |
const ImageRegion & | region, | |||
RegionHandler::GroupType | , | |||
Bool | overwrite = False | |||
) | [virtual] |
Define a region/mask belonging to the image.
The group type determines if it stored as a region or mask. If overwrite=False, an exception will be thrown if the region already exists.
An exception is thrown if canDefineRegion is False.
Bool casacore::ImageInterface< T >::fromRecord | ( | String & | error, | |
const RecordInterface & | inRec | |||
) |
virtual String casacore::ImageInterface< T >::getDefaultMask | ( | ) | const [virtual] |
Get the name of the default pixelmask.
An empty string is returned if no default pixelmask.
virtual ImageRegion* casacore::ImageInterface< T >::getImageRegionPtr | ( | const String & | name, | |
RegionHandler::GroupType | = RegionHandler::Any , |
|||
Bool | throwIfUnknown = True | |||
) | const [virtual] |
Get a region/mask belonging to the image from the given group (which can be Any).
Optionally an exception is thrown if the region does not exist. A zero pointer is returned if the region does not exist. The caller has to delete the ImageRegion
object created.
ImageRegion casacore::ImageInterface< T >::getRegion | ( | const String & | regionName, | |
RegionHandler::GroupType | = RegionHandler::Any | |||
) | const |
Get a region belonging to the image.
An exception is thrown if the region does not exist.
RegionHandler* casacore::ImageInterface< T >::getRegionHandler | ( | ) | [inline, protected] |
Get access to the region handler.
Definition at line 376 of file ImageInterface.h.
virtual Bool casacore::ImageInterface< T >::hasRegion | ( | const String & | regionName, | |
RegionHandler::GroupType | = RegionHandler::Any | |||
) | const [virtual] |
Does the image have a region with the given name?
const ImageInfo& casacore::ImageInterface< T >::imageInfo | ( | ) | const [inline] |
The ImageInfo object contains some miscellaneous information about the image which unlike that stored in MiscInfo, has a standard list of things, such as the restoring beam.
Note that setImageInfo REPLACES the information with the new information. It is up to the derived class to make the ImageInfo permanent.
Definition at line 240 of file ImageInterface.h.
virtual String casacore::ImageInterface< T >::imageType | ( | ) | const [pure virtual] |
Get the image type (returns name of derived class).
Reimplemented from casacore::LatticeBase.
Implemented in casacore::CurvedImage2D< T >, casacore::ExtendImage< T >, casacore::FITSErrorImage, casacore::FITSImage, casacore::FITSQualityImage, casacore::HDF5Image< T >, casacore::ImageConcat< T >, casacore::ImageExpr< T >, casacore::MIRIADImage, casacore::PagedImage< T >, casacore::RebinImage< T >, casacore::SubImage< T >, casacore::TempImage< T >, and casacore::ImageExpr< Bool >.
virtual LELCoordinates casacore::ImageInterface< T >::lelCoordinates | ( | ) | const [virtual] |
Function to get a LELCoordinate object containing the coordinates.
Reimplemented from casacore::LatticeBase.
const LoggerHolder& casacore::ImageInterface< T >::logger | ( | ) | const [inline] |
Definition at line 206 of file ImageInterface.h.
LoggerHolder& casacore::ImageInterface< T >::logger | ( | ) | [inline] |
Get access to the LoggerHolder.
Definition at line 204 of file ImageInterface.h.
Referenced by casacore::ImageInterface< Complex >::logSink().
const LogIO& casacore::ImageInterface< T >::logSink | ( | ) | const [inline] |
Definition at line 214 of file ImageInterface.h.
Referenced by casacore::ImageInterface< Complex >::logSink().
LogIO& casacore::ImageInterface< T >::logSink | ( | ) | [inline] |
Allow messages to be logged to this ImageInterface.
Definition at line 212 of file ImageInterface.h.
virtual ImageRegion casacore::ImageInterface< T >::makeMask | ( | const String & | name, | |
Bool | defineAsRegion = True , |
|||
Bool | setAsDefaultMask = True , |
|||
Bool | initialize = False , |
|||
Bool | value = True | |||
) | [virtual] |
Make a mask which is suitable for the type of image.
Optionally the mask can be initialized with the given value (by default it will not).
Optionally the mask can be defined as an image region/mask and turned in the default mask for the image. By default it will.
String casacore::ImageInterface< T >::makeUniqueRegionName | ( | const String & | rootName, | |
uInt | startNumber = 1 | |||
) | const |
Make a unique region name from the given root name, thus make it such that the name is not already in use for a region or mask.
The root name is returned if it is already unique. Otherwise a number is appended to the root name to make it unique. The number starts at the given number and is incremented until the name is unique.
const TableRecord& casacore::ImageInterface< T >::miscInfo | ( | ) | const [inline] |
Often we have miscellaneous information we want to attach to an image.
This is where it goes.
Note that setMiscInfo REPLACES the information with the new information. It can fail if, e.g., the underlying table is not writable.
Reimplemented in casacore::MIRIADImage.
Definition at line 228 of file ImageInterface.h.
virtual String casacore::ImageInterface< T >::name | ( | Bool | stripPath = False |
) | const [pure virtual] |
Return the name of the current ImageInterface object.
This will generally be a file name for images that have a persistent form. Any path before the actual file name can be optionally stripped off.
Reimplemented from casacore::LatticeBase.
Implemented in casacore::CurvedImage2D< T >, casacore::ExtendImage< T >, casacore::FITSImage, casacore::FITSQualityImage, casacore::HDF5Image< T >, casacore::ImageConcat< T >, casacore::ImageExpr< T >, casacore::MIRIADImage, casacore::PagedImage< T >, casacore::RebinImage< T >, casacore::SubImage< T >, casacore::TempImage< T >, and casacore::ImageExpr< Bool >.
virtual Bool casacore::ImageInterface< T >::ok | ( | ) | const [pure virtual] |
Check class invariants.
Reimplemented from casacore::LatticeBase.
Implemented in casacore::CurvedImage2D< T >, casacore::ExtendImage< T >, casacore::FITSImage, casacore::FITSQualityImage, casacore::HDF5Image< T >, casacore::ImageConcat< T >, casacore::ImageExpr< T >, casacore::MIRIADImage, casacore::PagedImage< T >, casacore::RebinImage< T >, casacore::SubImage< T >, casacore::TempImage< T >, and casacore::ImageExpr< Bool >.
ImageInterface& casacore::ImageInterface< T >::operator= | ( | const ImageInterface< T > & | other | ) | [protected] |
Assignment (copy semantics) is only useful for derived classes.
Reimplemented from casacore::MaskedLattice< T >.
Reimplemented in casacore::CurvedImage2D< T >, casacore::ExtendImage< T >, casacore::HDF5Image< T >, casacore::ImageConcat< T >, casacore::ImageExpr< T >, casacore::PagedImage< T >, casacore::RebinImage< T >, casacore::SubImage< T >, and casacore::TempImage< T >.
virtual Vector<String> casacore::ImageInterface< T >::regionNames | ( | RegionHandler::GroupType | = RegionHandler::Any |
) | const [virtual] |
Get the names of all regions/masks.
virtual void casacore::ImageInterface< T >::removeRegion | ( | const String & | name, | |
RegionHandler::GroupType | = RegionHandler::Any , |
|||
Bool | throwIfUnknown = True | |||
) | [virtual] |
Remove a region/mask belonging to the image from the given group (which can be Any).
Optionally an exception is thrown if the region does not exist.
Reimplemented in casacore::HDF5Image< T >, casacore::PagedImage< T >, and casacore::TempImage< T >.
virtual void casacore::ImageInterface< T >::renameRegion | ( | const String & | newName, | |
const String & | oldName, | |||
RegionHandler::GroupType | = RegionHandler::Any , |
|||
Bool | overwrite = False | |||
) | [virtual] |
Rename a region.
If a region with the new name already exists, it is deleted or an exception is thrown (depending on overwrite
). The region name is looked up in the given group(s).
An exception is thrown if the old region name does not exist.
virtual void casacore::ImageInterface< T >::resize | ( | const TiledShape & | newShape | ) | [pure virtual] |
Function which changes the shape of the image (N.B.
the data is thrown away - the Image will be filled with nonsense afterwards)
Implemented in casacore::CurvedImage2D< T >, casacore::ExtendImage< T >, casacore::FITSImage, casacore::FITSQualityImage, casacore::HDF5Image< T >, casacore::ImageConcat< T >, casacore::ImageExpr< T >, casacore::MIRIADImage, casacore::PagedImage< T >, casacore::RebinImage< T >, casacore::SubImage< T >, casacore::TempImage< T >, and casacore::ImageExpr< Bool >.
Bool casacore::ImageInterface< T >::restoreImageInfo | ( | const RecordInterface & | rec | ) | [protected] |
Restore the image info from the record.
Reimplemented in casacore::HDF5Image< T >.
ImageAttrHandler& casacore::ImageInterface< T >::roAttrHandler | ( | ) | const [inline] |
Definition at line 249 of file ImageInterface.h.
ImageInfo& casacore::ImageInterface< T >::rwImageInfo | ( | ) | [inline, protected] |
Get non-const access to the ImageInfo.
Definition at line 380 of file ImageInterface.h.
virtual Bool casacore::ImageInterface< T >::setCoordinateInfo | ( | const CoordinateSystem & | coords | ) | [virtual] |
Functions to set or replace the coordinate information in the Image Returns False on failure, e.g.
if the number of axes do not match.
Reimplemented in casacore::HDF5Image< T >, and casacore::PagedImage< T >.
void casacore::ImageInterface< T >::setCoordsMember | ( | const CoordinateSystem & | coords | ) | [inline, protected] |
Set the coordinate system variable.
Definition at line 364 of file ImageInterface.h.
virtual void casacore::ImageInterface< T >::setDefaultMask | ( | const String & | regionName | ) | [virtual] |
Set the default pixelmask to the mask with the given name (which has to exist in the "masks" group).
If the image table is writable, the setting is persistent by writing the name as a keyword. If the given regionName is the empty string, the default pixelmask is unset.
Reimplemented in casacore::HDF5Image< T >, casacore::PagedImage< T >, and casacore::TempImage< T >.
virtual Bool casacore::ImageInterface< T >::setImageInfo | ( | const ImageInfo & | info | ) | [virtual] |
Reimplemented in casacore::HDF5Image< T >, and casacore::PagedImage< T >.
void casacore::ImageInterface< T >::setImageInfoMember | ( | const ImageInfo & | imageInfo | ) | [protected] |
Set the image info variable.
void casacore::ImageInterface< T >::setLogMember | ( | const LoggerHolder & | logger | ) | [inline, protected] |
Set the image logger variable.
Definition at line 357 of file ImageInterface.h.
virtual Bool casacore::ImageInterface< T >::setMiscInfo | ( | const RecordInterface & | newInfo | ) | [virtual] |
Reimplemented in casacore::HDF5Image< T >, casacore::MIRIADImage, and casacore::PagedImage< T >.
void casacore::ImageInterface< T >::setMiscInfoMember | ( | const RecordInterface & | rec | ) | [inline, protected] |
Set the miscinfo variable.
Definition at line 372 of file ImageInterface.h.
void casacore::ImageInterface< T >::setUnitMember | ( | const Unit & | unit | ) | [inline, protected] |
Set the unit variable.
Definition at line 368 of file ImageInterface.h.
virtual Bool casacore::ImageInterface< T >::setUnits | ( | const Unit & | newUnits | ) | [virtual] |
Function which get and set the units associated with the image pixels (i.e.
the "brightness" unit). setUnits()
returns False if it cannot set the unit for some reason (e.g. the underlying file is not writable).
Reimplemented in casacore::HDF5Image< T >, and casacore::PagedImage< T >.
Bool casacore::ImageInterface< T >::toRecord | ( | String & | error, | |
RecordInterface & | outRec | |||
) |
Save and restore an ImageInterface object to or from a state Record.
virtual const Unit& casacore::ImageInterface< T >::units | ( | ) | const [inline, virtual] |
Definition at line 182 of file ImageInterface.h.
virtual void casacore::ImageInterface< T >::useMask | ( | MaskSpecifier | = MaskSpecifier() |
) | [virtual] |
Use the mask as specified.
If a mask was already in use, it is replaced by the new one.
Reimplemented in casacore::HDF5Image< T >, casacore::PagedImage< T >, and casacore::TempImage< T >.
CoordinateSystem casacore::ImageInterface< T >::coords_p [private] |
It is the job of the derived class to make these variables valid.
Definition at line 385 of file ImageInterface.h.
Referenced by casacore::ImageInterface< Complex >::coordinates(), and casacore::ImageInterface< Complex >::setCoordsMember().
ImageInfo casacore::ImageInterface< T >::imageInfo_p [private] |
Definition at line 387 of file ImageInterface.h.
Referenced by casacore::ImageInterface< Complex >::imageInfo(), and casacore::ImageInterface< Complex >::rwImageInfo().
ImageAttrHandler casacore::ImageInterface< T >::itsBaseAttrHandler [private] |
The attribute handling object.
Definition at line 395 of file ImageInterface.h.
LoggerHolder casacore::ImageInterface< T >::log_p [private] |
Definition at line 386 of file ImageInterface.h.
Referenced by casacore::ImageInterface< Complex >::appendLog(), casacore::ImageInterface< Complex >::logger(), and casacore::ImageInterface< Complex >::setLogMember().
TableRecord casacore::ImageInterface< T >::miscInfo_p [private] |
Definition at line 389 of file ImageInterface.h.
Referenced by casacore::ImageInterface< Complex >::miscInfo(), and casacore::ImageInterface< Complex >::setMiscInfoMember().
RegionHandler* casacore::ImageInterface< T >::regHandPtr_p [private] |
The region handling object.
Definition at line 392 of file ImageInterface.h.
Referenced by casacore::ImageInterface< Complex >::canDefineRegion(), and casacore::ImageInterface< Complex >::getRegionHandler().
Unit casacore::ImageInterface< T >::unit_p [private] |
Reimplemented in casacore::ImageExpr< T >, casacore::MIRIADImage, and casacore::ImageExpr< Bool >.
Definition at line 388 of file ImageInterface.h.
Referenced by casacore::ImageInterface< Complex >::setUnitMember(), and casacore::ImageInterface< Complex >::units().