casa
$Rev:20696$
|
Class to define a world coordinate box region of interest in an image. More...
#include <WCBox.h>
Public Member Functions | |
WCBox () | |
WCBox (const Vector< Quantum< Double > > &blc, const Vector< Quantum< Double > > &trc, const CoordinateSystem &cSys, const Vector< Int > &absRel) | |
Construct from vectors of world coordinates defining the box corners. | |
WCBox (const Vector< Quantum< Double > > &blc, const Vector< Quantum< Double > > &trc, const IPosition &pixelAxes, const CoordinateSystem &cSys, const Vector< Int > &absRel) | |
Construct from vectors of world coordinates defining the box corners. | |
WCBox (const LCRegion ®ion, const CoordinateSystem &cSys) | |
Construct from the bounding box of an LCRegion . | |
WCBox (const WCBox &other) | |
Copy constructor (reference semantics [except for CoordinateSystem ]) | |
virtual | ~WCBox () |
Destructor. | |
WCBox & | operator= (const WCBox &other) |
Assignment (copy semantics) | |
virtual Bool | operator== (const WCRegion &other) const |
Comparison. | |
virtual WCRegion * | cloneRegion () const |
Clone a WCBox object. | |
virtual Bool | canExtend () const |
WCBox can extend a region. | |
WCBox | splitBox (const IPosition &axes) const |
Make a new box from the given axesin this box. | |
virtual LCRegion * | doToLCRegion (const CoordinateSystem &cSys, const IPosition &latticeShape, const IPosition &pixelAxesMap, const IPosition &outOrder) const |
Convert to an LCRegion using the supplied CoordinateSystem and shape. | |
virtual TableRecord | toRecord (const String &tableName) const |
Convert the WCBox object to a record. | |
virtual String | type () const |
Return region type. | |
Static Public Member Functions | |
static WCBox * | fromRecord (const TableRecord &rec, const String &tableName) |
Convert to a WCBox from a record. | |
static String | className () |
Returns WCBox. | |
Private Member Functions | |
void | checkUnits (const IPosition &pixelAxes, const Vector< Quantum< Double > > &values, const CoordinateSystem &cSys) |
Check units of quanta are consistent with CoordinateSystem. | |
void | convertPixel (Double &pixel, const Quantum< Double > &value, const Int absRel, const Double refPix, const Int shape, const Bool isBlc) const |
Convert relative pixels to absolute or fill in defaults. | |
Private Attributes | |
Vector< Quantum< Double > > | itsBlc |
Vector< Quantum< Double > > | itsTrc |
IPosition | itsPixelAxes |
CoordinateSystem | itsCSys |
Vector< Int > | itsAbsRel |
Bool | itsNull |
Class to define a world coordinate box region of interest in an image.
Public interface
The corners of the box are specified in world coordinates, but the region enclosed by those corners is a box in lattice coordinates. Thus, the volume enclosed does not follow world coordinate contours.
All this class does, apart from constructing itself, is know how to save itself to a Record
and how to convert itself to an LCRegion
. The conversion allows you to apply a WCBox
constructed with one CoordinateSystem
to another CoordinateSystem
. That is, you can apply a WCBox
from this image to that image.
The flexibility of the CoordinateSystem
class should be kept in mind when using this class. Recall that a CoordinateSystem
has world and pixel axes, and that these axes can be independently removed and independently (re)ordered.
During construction, the length of the world coordinate vectors may be smaller than the number world axes in the supplied CoordinateSystem
. It is assumed that the units of the world coordinates are the same as those encapsulated in the construction CoordinateSystem
and in the same order as specified (either intrinsically, or by the world axes specification vectors).
The following rules are followed during conversion to an LCRegion
.
latticeShape
must be equal to the number of pixel axes in the supplied CoordinateSystem
. CoordinateSystem
is assumed to be the order of the axes in the lattice for which the supplied latticeShape
is appropriate. CoordinateSystem
supplied to the toLCRegion
function does not have to be identical in structure to that from which the WCBox
was constructed. They can consist of different numbers of world and pixel axes and be in different orders. CoordinateSystem
that is also present (somewhere) in the construction CoordinateSystem
the blc/trc corresponding to that world axis will be converted to pixels appropriate to the supplied CoordinateSystem
. The order of this pixel based blc/trc will be the order of the pixel axes of the supplied CoordinateSystem
CoordinateSystem
that is not present in the construction CoordinateSystem
, the supplied latticeShape
value for the corresponding pixel axis is used, setting blc=0
and trc=latticeShape-1
for that axis. latticeShape
, it is used to create the LCBox
, which is supplied as a pointer to the base class LCRegion
. Note that when determining whether a world axis from one CoordinateSystem
is present on another, it is considered to not be a match if two coordinates of the same type (e.g. DirectionCoordinate
) have different specific types (e.g. J2000 and GALACTIC, or TOPO and LSR for a SpectralCoordinate
)
Let us give some examples with pseudo-code. cSys is the construction CoordinateSystem and cSys2 is the supplied CoordinateSystem. We list their world axes in the square brackets. The construction blc/trc values don't matter as long as there cSys.nWorldAxes() of them. Similarly, the values of shape don't matter as long as there are cSys2.nPixelAxes() of them.
cSys = [ra, dec, freq]; cSys2 = [ra, dec]; blc = [,,]; trc = [,,]; shape = [,]; WCBox box(blc, trc, cSys); LCRegion* pR = box.toLCRegion(cSys2, shape);
The resultant LCBox will have corners converted according to
blcLC(0) <- blc(0); blcLC(1) <- blc(1); trcLC(0) <- trc(0); trcLC(1) <- trc(1);
cSys = [ra, dec, freq]; cSys2 = [freq, stokes]; blc = [,,]; trc = [,,]; shape = [,]; WCBox box(blc, trc, cSys); LCRegion* pR = box.toLCRegion(cSys2, shape);
The resultant LCBox will have corners converted according to
blcLC(0) <- blc(2); blcLC(1) = 0; trcLC(0) <- trc(2); trcLC(1) = shape(1) - 1;
cSys = [ra, dec]; cSys2 = [ra, dec, freq]; blc = [,]; trc = [,]; shape = [,,]; WCBox box(blc, trc, cSys); LCRegion* pR = box.toLCRegion(cSys2, shape);
The resultant LCBox will have corners converted according to
blcLC(0) <- blc(0); blcLC(1) <- blc(1); blcLC(2) = 0l trcLC(0) <- trc(0); trcLC(1) <- trc(1); trcLC(2) = shape(2)-1;
cSys = [ra, dec, freq]; cSys2 = [freq, ra, dec]; blc = [,,]; trc = [,,]; shape = [,,]; WCBox box(blc, trc, cSys); LCRegion* pR = box.toLCRegion(cSys2, shape);
The resultant LCBox will have corners converted according to
blcLC(0) <- blc(2); blcLC(1) <- blc(0); blcLC(2) <- blc(1); trcLC(0) <- trc(2); trcLC(1) <- trc(0); trcLC(2) <- trc(1);
In this example we make it a bit harder by reordering the pixel axes too. The new order of the pixel axes in terms of the original order [0,1,2] is given after the world axes
cSys = [ra, dec, freq], [0, 1, 2]; cSys2 = [freq, ra, dec, stokes], [3, 0, 2, 1]; blc = [,,]; trc = [,,]; shape = [,,,]; WCBox box(blc, trc, cSys); LCRegion* pR = box.toLCRegion(cSys2, shape);
Take the first world axis of cSys2 as an example. First, "freq" is found as the world axis number 2 in cSys. Then, when it is converted to a pixel coordinate, it will turn up as the value on pixel axis 1. The supplied shape must be appropriate to a [stokes, freq, dec, ra] lattice. The resultant LCBox will therefore have corners converted according to
blcLC(0) = 0 blcLC(1) <- blc(2); blcLC(2) <- blc(1); blcLC(3) <- blc(0); trcLC(0) = shape(0)-1; trcLC(1) <- trc(2); trcLC(2) <- trc(1); trcLC(3) <- trc(0);
Users must be able to specify regions in world as well as lattice coordinates.
Note: In all of the constructors, the order of the specified world coordinates is that of the PIXEL AXES (not world axes) in the CoordinateSystem
; This is the natural order for a user to want to specify them in;
Note: For the constructors specifying the world values as simple doubles, it is ASSUMED that the units of those doubles are the same as the native units of the CoordinateSystem
for each axis;
Note: World coordinates may be specified as absolute or offset; If the latter, they are offset with respect to the reference pixel of the CoordinateSystem
;
casa::WCBox::WCBox | ( | const Vector< Quantum< Double > > & | blc, |
const Vector< Quantum< Double > > & | trc, | ||
const CoordinateSystem & | cSys, | ||
const Vector< Int > & | absRel | ||
) |
Construct from vectors of world coordinates defining the box corners.
It is assumed that the order of the values is in the order of the pixel axes in the given coordinate system.
casa::WCBox::WCBox | ( | const Vector< Quantum< Double > > & | blc, |
const Vector< Quantum< Double > > & | trc, | ||
const IPosition & | pixelAxes, | ||
const CoordinateSystem & | cSys, | ||
const Vector< Int > & | absRel | ||
) |
Construct from vectors of world coordinates defining the box corners.
You specify the pixel axis order of the world values.
casa::WCBox::WCBox | ( | const LCRegion & | region, |
const CoordinateSystem & | cSys | ||
) |
Construct from the bounding box of an LCRegion
.
casa::WCBox::WCBox | ( | const WCBox & | other | ) |
Copy constructor (reference semantics [except for CoordinateSystem
])
virtual casa::WCBox::~WCBox | ( | ) | [virtual] |
Destructor.
virtual Bool casa::WCBox::canExtend | ( | ) | const [virtual] |
WCBox can extend a region.
Reimplemented from casa::WCRegion.
void casa::WCBox::checkUnits | ( | const IPosition & | pixelAxes, |
const Vector< Quantum< Double > > & | values, | ||
const CoordinateSystem & | cSys | ||
) | [private] |
Check units of quanta are consistent with CoordinateSystem.
static String casa::WCBox::className | ( | ) | [static] |
Returns WCBox.
virtual WCRegion* casa::WCBox::cloneRegion | ( | ) | const [virtual] |
Clone a WCBox object.
Implements casa::WCRegion.
void casa::WCBox::convertPixel | ( | Double & | pixel, |
const Quantum< Double > & | value, | ||
const Int | absRel, | ||
const Double | refPix, | ||
const Int | shape, | ||
const Bool | isBlc | ||
) | const [private] |
Convert relative pixels to absolute or fill in defaults.
virtual LCRegion* casa::WCBox::doToLCRegion | ( | const CoordinateSystem & | cSys, |
const IPosition & | latticeShape, | ||
const IPosition & | pixelAxesMap, | ||
const IPosition & | outOrder | ||
) | const [virtual] |
Convert to an LCRegion using the supplied CoordinateSystem
and shape.
Implements casa::WCRegion.
static WCBox* casa::WCBox::fromRecord | ( | const TableRecord & | rec, |
const String & | tableName | ||
) | [static] |
Convert to a WCBox from a record.
Reimplemented from casa::WCRegion.
Comparison.
Reimplemented from casa::WCRegion.
WCBox casa::WCBox::splitBox | ( | const IPosition & | axes | ) | const |
Make a new box from the given axesin this box.
virtual TableRecord casa::WCBox::toRecord | ( | const String & | tableName | ) | const [virtual] |
Convert the WCBox object to a record.
The record can be used to make the object persistent. The tableName
argument can be used by derived classes (e.g. LCPagedMask) to put very large objects.
Implements casa::WCRegion.
virtual String casa::WCBox::type | ( | ) | const [virtual] |
Vector<Int> casa::WCBox::itsAbsRel [private] |
CoordinateSystem casa::WCBox::itsCSys [private] |
Bool casa::WCBox::itsNull [private] |
IPosition casa::WCBox::itsPixelAxes [private] |