ImageConcat.h

Classes

ImageConcat -- Concatenates images along a specified axis (full description)

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

Interface

Public Members
ImageConcat (uInt axis, Bool tempClose=True)
ImageConcat()
ImageConcat (const ImageConcat<T> &other)
virtual ~ImageConcat()
ImageConcat<T> &operator= (const ImageConcat<T> &other)
virtual ImageInterface<T>* cloneII() const
virtual String imageType() const
void setImage (ImageInterface<T>& image, Bool relax)
void setLattice (MaskedLattice<T>& lattice)
uInt nimages() const
uInt axis () const
uInt imageDim() const
virtual Bool lock (FileLocker::LockType, uInt nattempts)
virtual void unlock()
virtual Bool hasLock (FileLocker::LockType) const
virtual void resync()
virtual void flush()
virtual void tempClose()
virtual void reopen()
virtual String name (Bool stripPath=False) const
virtual Bool isMasked() const
virtual Bool hasPixelMask() const
virtual const Lattice<Bool>& pixelMask() const
virtual Lattice<Bool>& pixelMask()
virtual const LatticeRegion* getRegionPtr() const
virtual Bool isWritable() const
virtual IPosition shape() const
virtual IPosition doNiceCursorShape (uInt maxPixels) const
virtual Bool doGetSlice (Array<T>& buffer, const Slicer& section)
virtual Bool doGetMaskSlice (Array<Bool>& buffer, const Slicer& section)
virtual void doPutSlice (const Array<T>& sourceBuffer, const IPosition& where, const IPosition& stride)
virtual void resize(const TiledShape&)
virtual Bool ok() const
virtual LatticeIterInterface<T> *makeIter (const T &navigator, Bool useRef) const
Private Members
Double coordConvert(Int& worldAxis, LogIO& os, const CoordinateSystem& cSys, uInt axis, Double pixelCoord) const
void checkContiguous (Bool& isContig, Bool& warnContig, const IPosition& shape1, const CoordinateSystem& cSys1, const CoordinateSystem& cSys2, LogIO& os, uInt axis, Bool relax)
void checkNonConcatAxisCoordinates (Bool& warnRefPix, Bool& warnRefVal, Bool& warnInc, LogIO& os, const ImageInterface<T>& image, Bool relax)
Vector<Int> makeNewStokes(const Vector<Int>& stokes1, const Vector<Int>& stokes2)
void setCoordinates()

Description

Review Status

Date Reviewed:
yyyy/mm/dd

Prerequisite

Etymology

This is a class designed to concatenate images along a specified axis

Synopsis

This is a class designed to concatenate images along a specified axis. This means you can join them together. E.g., join images of shape [10,20,30] and [10,20,40] into a lattice of shape [10,20,70].

The ImageConcat object does not copy the input images, it just references them. You can use the Lattice::copyData(Lattice) function to fill an output image with the concatenated input images

If you use the putSlice function, be aware that it will change the underlying images if they are writable.

You can also concatenate a lattice to an image.

Example

         IPosition shape(2, 10, 20);
         PagedImage<Float> im1(shape, CoordinateUtil::defaultCoords2D(),
                               "tImageConcat_tmp1.img");
         im1.set(1.0);
         PagedImage<Float> im2(shape, CoordinateUtil::defaultCoords2D(),
                               "tImageConcat_tmp2.img");
         im2.set(2.0);
    
    // Make concatenator for axis 0
    
         ImageConcat<Float> concat(0);
    
    // Relax coordinate constraints
    
         concat.setImage(im1, True);
         concat.setImage(im2, True);
    
    // Make output image  and mask (if required, which it will be in this case)
    
         PagedImage<Float> im3(concat.shape(), CoordinateUtil::defaultCoords2D(),
                               "tImageConcat_tmp3.img");
    
    // Copy to output
    
         im3.copyData(concat);
    
    
See tImageConcat.cc for more examples.

Motivation

Image concatentation is a useful enduser requirement.

To Do

Member Description

ImageConcat (uInt axis, Bool tempClose=True)

Constructor. Specify the pixel axis for concatenation

ImageConcat()

Default constructor, Sets the concatenation axis to 0

ImageConcat (const ImageConcat<T> &other)

Copy constructor (reference semantics)

virtual ~ImageConcat()

Destructor

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

Assignment operator (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).

void setImage (ImageInterface<T>& image, Bool relax)

Sets a new image into the list to be concatenated. If relax is False, throws an exception if the images are not contiguous along the concatenation axis. If relax is True, it will create a non-regular TabularCoordinate for non-contiguous images if the coordinates are monotonic. Otherwise, it just uses the coordinates of the image

void setLattice (MaskedLattice<T>& lattice)

Sets a new lattice into the list to be concatenated. You can only concatenate a lattice with an image if you have first used setImage to set an image (this provides the CooridinateSystem information)

uInt nimages() const

Return the number of images/lattices set so far

uInt axis () const

Returns the current concatenation axis (0 relative)

uInt imageDim() const

Returns the number of dimensions of the *input* images/lattices Returns 0 if none yet set.

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

Handle the (un)locking and syncing, etc..

virtual String name (Bool stripPath=False) const

Return the name of the current ImageInterface object. Since many images may be concatenated, there is no sensible name. So returns the string "Concatenation :"

virtual Bool isMasked() const

Has the object really a mask?

virtual Bool hasPixelMask() const

Does the image have a pixelmask?

virtual const Lattice<Bool>& pixelMask() const
virtual Lattice<Bool>& pixelMask()

Get access to the pixelmask. An exception is thrown if the image does not have a pixelmask

virtual const LatticeRegion* getRegionPtr() const

Get the region used (always returns 0)

virtual Bool isWritable() const

If all of the underlying lattices are writable returns True

virtual IPosition shape() const

Return the shape of the concatenated image

virtual IPosition doNiceCursorShape (uInt maxPixels) const

Return the best cursor shape. This isn't very meaningful for an ImageConcat Image since it isn't on disk ! But if you do copy it out, this is what you should use. The maxPixels aregument is ignored.

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

Do the actual get of the data. The return value is always False, thus the buffer does not reference another array. Generally the user should use function getSlice

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. Generally the user should use function getMaskSlice

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

Do the actual put of the data into the Lattice. This will change the underlying images (if they are writable) that were used to create the ImageConcat object. It throws an exception if not writable. Generally the user should use function putSlice

virtual void resize(const TiledShape&)

Throws an excpetion as you cannot reshape an ImageConcat object

virtual Bool ok() const

Check class invariants.

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

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

Double coordConvert(Int& worldAxis, LogIO& os, const CoordinateSystem& cSys, uInt axis, Double pixelCoord) const

void checkContiguous (Bool& isContig, Bool& warnContig, const IPosition& shape1, const CoordinateSystem& cSys1, const CoordinateSystem& cSys2, LogIO& os, uInt axis, Bool relax)

void checkNonConcatAxisCoordinates (Bool& warnRefPix, Bool& warnRefVal, Bool& warnInc, LogIO& os, const ImageInterface<T>& image, Bool relax)

Vector<Int> makeNewStokes(const Vector<Int>& stokes1, const Vector<Int>& stokes2)

void setCoordinates()