#include <Slice.h>
A "slice" (aka Section) is a a regular sub-Array (and ultimately sub-Image) that is defined by defining a (start,length,increment) for each axis in the array. That is, the output array's axis is of size "length", and the elements are sampled by stepping along the input array in strides of "increment". Warning: The "length" is the length of the OUTPUT array, the output length is NOT divided by the increment/stride. If increment is not defined, then it defaults to one. (Increment, if defined, must be >= 1). If length is not defined, then it defaults to a length of one also (i.e. just the pixel "start"). If start is also undefined, then all pixels along this axis are chosen. This class deprecates the "_" (IndexRange) class, which had a failed syntax and used (start,end,increment) which is generally less convenient. Some simple examples follow:
Vector<Int> vi(100); // Vector of length 100; //.\.. // Copy odd values onto even values vi(Slice(0,50,2)) = vi(Slice(1,50,2)); Matrix<float> mf(100,50), smallMf; smallMf.reference(mf(Slice(0,10,10), Slice(0,5,10))); // smallMF is now a "dezoomed" (every 10th pix) // refference to mf. Of course we could also // make it a copy by using assignment; e.g: smallMf.resize(0,0); // Make it so it will "size to fit" smallMf = mf(Slice(0,10,10), Slice(0,5,10));
While it will be unusual for a user to want this, a zero-length slice is allowable.
Another way to produce a slice from any of the Array classes is to use SomeArray(blc,trc,inc) where blc,trc,inc are IPositions. This is described in the documentation for Array<T>.
Definition at line 87 of file Slice.h.
Public Member Functions | |
| Slice () | |
| The entire range of indices on the axis is desired. | |
| Slice (Int Start, uInt Length=1, uInt Inc=1) | |
| Create a Slice with a given start, length, and increment. | |
| Bool | all () const |
| Was the entire range of indices on this axis selected? | |
| Int | start () const |
| Report the selected starting position. | |
| uInt | length () const |
| Report the defined length. | |
| uInt | inc () const |
| Report the defined increment. | |
| Int | end () const |
| Attempt to report the last element of the slice. | |
Private Attributes | |
| Int | startp |
| Int | incp |
| uInt | lengthp |
| casa::Slice::Slice | ( | ) | [inline] |
Create a Slice with a given start, length, and increment.
The latter two default to one if not given.
Definition at line 126 of file Slice.h.
References DebugAssert, and incp.
| Bool casa::Slice::all | ( | ) | const [inline] |
Was the entire range of indices on this axis selected?
Definition at line 134 of file Slice.h.
References casa::False, incp, and casa::True.
Referenced by inc().
| Int casa::Slice::start | ( | ) | const [inline] |
| uInt casa::Slice::length | ( | ) | const [inline] |
| uInt casa::Slice::inc | ( | ) | const [inline] |
| Int casa::Slice::end | ( | ) | const [inline] |
Int casa::Slice::startp [private] |
Int casa::Slice::incp [private] |
uInt casa::Slice::lengthp [private] |
1.5.1