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.
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... };
Construct for a specific region handler object.
Copy constructor (copy semantics).
Make a copy of the derived object (reference semantics).
Get the image type (returns name of derived class).
Function which changes the shape of the image (N.B. the data is thrown away - the Image will be filled with nonsense afterwards)
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).
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.
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.
Function to get a LELCoordinate object containing the coordinates.
Get access to the LoggerHolder.
Allow messages to be logged to this ImageInterface.
Add the messages from the other image logger to this one.
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.
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.
Can the image handle region definition?
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.
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.
Does the image have a region with the given name?
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.
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.
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.
Get the names of all regions/masks.
Use the mask as specified. If a mask was already in use, it is replaced by the new one.
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.
Get the name of the default pixelmask. An empty string is returned if no default pixelmask.
Get a region belonging to the image. An exception is thrown if the region does not exist.
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.
Check class invariants.
Save and restore an ImageInterface object to or from a state Record
Restore the image info from the record.
Set the image logger variable.
Set the image info variable.
Set the coordinate system variable.
Set the unit variable.
Set the miscinfo variable.