ImageExpr.h

Classes

ImageExpr -- Hold mathematical expressions involving ImageInterface objects (full description)

template <class T> class ImageExpr: public ImageInterface<T>

Interface

Public Members
ImageExpr()
ImageExpr(const LatticeExpr<T>& latticeExpr, const String& name)
ImageExpr(const ImageExpr<T>& other)
~ImageExpr()
ImageExpr<T>& operator=(const ImageExpr<T>& other)
virtual ImageInterface<T>* cloneII() const
virtual String imageType() const
virtual Bool isMasked() const
virtual const LatticeRegion* getRegionPtr() const
virtual IPosition shape() const
virtual void resize(const TiledShape& newShape)
virtual Bool doGetMaskSlice (Array<Bool>& buffer, const Slicer& section)
virtual Bool doGetSlice (Array<T>& buffer, const Slicer& theSlice)
virtual void doPutSlice (const Array<T>& sourceBuffer, const IPosition& where, const IPosition& stride)
virtual String name (Bool stripPath=False) const
virtual Bool ok() const
virtual LatticeIterInterface<T>* makeIter( const LatticeNavigator& navigator, Bool useRef) const
virtual Bool isWritable() const
virtual IPosition doNiceCursorShape (uInt maxPixels) const
virtual Bool lock (FileLocker::LockType, uInt nattempts)
virtual void unlock()
virtual Bool hasLock (FileLocker::LockType) const
virtual void resync()
virtual void tempClose()
virtual void reopen()
const LatticeExpr<T>& expression() const

Description

Review Status

Programs:
Tests:

Prerequisite

Etymology

This class holds a LatticeExpr object but inherits from ImageInterface hence ImageExpr

Synopsis

An ImageExpr object holds a LatticeExpr object which can be used to evaluate mathematical expressions involving Lattices. ImageExpr exists so that direct manipulation of LatticeExpr objects by methods expecting an ImageInterface, rather than a Lattice can occur.

The ImageExpr object is constructed from a LatticeExpr object, but only if the latter has true Coordinates associated with it. The ImageExpr object is not writable, so the ImageExpr object functions like a read only ImageInterface.

Example

    PagedImage<Float> a("imageB");                // Open PagedImages
    PagedImage<Float> b("imageB");

    LatticeExprNode node(a+b);                    // Create ImageExpr
    LatticeExpr<Float> lExpr(node);
    ImageExpr<Float> iExpr(lExpr);

    LogOrigin or("imageImpl", "main()", WHERE);   // Create statistics object
    LogIO logger(or);
    ImageStatistics<Float> stats(iExpr, logger);
    Bool ok = stats.display();                              // Display statistics
    
The ImageExpr object is evaluated during the call to stats.dislay(). Previously, the expression tree has been constructed, but not evaluated.

Motivation

This enables one to evaluate expressions but not to have to write them out to an output image.

To Do

Member Description

ImageExpr()

The default constructor

ImageExpr(const LatticeExpr<T>& latticeExpr, const String& name)

Construct an ImageExpr from a LatticeExpr. The name given could be the original expression string. The prefix "Expression: " is added to the name if not empty. The function name() returns this name (including possible prefix).

ImageExpr(const ImageExpr<T>& other)

Copy constructor (reference semantics)

~ImageExpr()

Destructor does nothing

ImageExpr<T>& operator=(const ImageExpr<T>& other)

Assignment (reference semantics)

virtual ImageInterface<T>* cloneII() const

Make a copy of the object (reference semantics).

virtual String imageType() const

Get the image type (returns name of derived class).

virtual Bool isMasked() const

Has the object really a mask?

virtual const LatticeRegion* getRegionPtr() const

Get the region used.

virtual IPosition shape() const

return the shape of the ImageExpr

virtual void resize(const TiledShape& newShape)

Function which changes the shape of the ImageExpr. Throws an exception as ImageExpr is not writable.

virtual Bool doGetMaskSlice (Array<Bool>& buffer, const Slicer& section)

Do the actual get of the mask data. The return value is always False, thus the buffer does not reference another array.

virtual Bool doGetSlice (Array<T>& buffer, const Slicer& theSlice)

Do the actual get of the data.

virtual void doPutSlice (const Array<T>& sourceBuffer, const IPosition& where, const IPosition& stride)

putSlice is not possible on an expression, so it throws an exception.

virtual String name (Bool stripPath=False) const

Return the name of the current ImageInterface object. Returns the expression string given in the constructor.

virtual Bool ok() const

Check class invariants.

virtual LatticeIterInterface<T>* makeIter( const LatticeNavigator& navigator, Bool useRef) const

These are the implementations of the LatticeIterator letters. not for public use

virtual Bool isWritable() const

Returns False, as the ImageExpr is not writable.

virtual IPosition doNiceCursorShape (uInt maxPixels) const

Help the user pick a cursor for most efficient access if they only want pixel values and don't care about the order or dimension of the cursor.

virtual Bool lock (FileLocker::LockType, uInt nattempts)
virtual void unlock()
virtual Bool hasLock (FileLocker::LockType) const
virtual void resync()
virtual void tempClose()
virtual void reopen()

Handle the (un)locking and syncing.

const LatticeExpr<T>& expression() const

Get the lattice expression.