Template for Variable-Typed Data Arrays. More...
#include <cmtkTemplateArray.h>
Public Types | |
typedef TemplateArray< T > | Self |
This type. | |
typedef TypedArray | Superclass |
Base class. | |
typedef SmartPointer< Self > | SmartPtr |
Smart pointer. | |
typedef DataTypeTraits< T > | TypeTraits |
Data type traits. | |
Public Member Functions | |
const T * | GetDataPtrConcrete () const |
Return const pointer to actual data. | |
T * | GetDataPtrConcrete () |
Return pointer to actual data. | |
void | SetPaddingValueTemplate (const T paddingData) |
Set the value to mark non-existent data using template data type. | |
TemplateArray (void *const data, const size_t datasize, const bool freeArray, const bool paddingflag, const void *paddingData) | |
Constructor. | |
TemplateArray (const size_t datasize=0) | |
Constructor. | |
virtual | ~TemplateArray () |
Destructor. | |
virtual void | SetPaddingValue (const Types::DataItem paddingData) |
Set the value to mark non-existent data using interface data type. | |
virtual void | SetPaddingPtr (const void *paddingData) |
Set the value to mark non-existent data using interface data type. | |
virtual void | ReplacePaddingData (const Types::DataItem value=0) |
Replace Padding data (padding) with given value. | |
virtual bool | IsPaddingAt (const size_t index) const |
Check for NULL data at given index. | |
virtual bool | IsPaddingOrZeroAt (const size_t index) const |
Check for PADDING data or zero value at given index. | |
virtual void | SetPaddingAt (const size_t index=0) |
Set the specified array element to no data present. | |
virtual ScalarDataType | GetType () const |
Return id of primitive data type handled by this object. | |
virtual size_t | GetItemSize () const |
Return size in bytes of the primitive data type handled by this object. | |
virtual void * | GetDataPtr (const size_t offset=0) |
Return pointer to an element in this objects data array. | |
virtual const void * | GetDataPtr (const size_t offset=0) const |
Return const pointer to an element in this objects data array. | |
virtual T * | GetDataPtrTemplate (const size_t offset=0) |
Return pointer to an element in this objects data array. | |
virtual const T * | GetDataPtrTemplate (const size_t offset=0) const |
Return const pointer to an element in this objects data array. | |
virtual Types::DataItem * | GetSubArray (Types::DataItem *const toPtr, const size_t fromIdx, const size_t len, const Types::DataItem substPadding=0) const |
Convert and copy continuous sub-array to a given destination. | |
virtual Types::DataItem * | GetSubArray (const size_t fromIdx, const size_t len, const Types::DataItem substPadding=0) const |
Return a sub array of the current instance. | |
virtual T | ConvertItem (const Types::DataItem value) |
Convert Types::DataItem to template type. | |
virtual TypedArray::SmartPtr | Convert (const ScalarDataType dtype) const |
Convert to typed array of any given template type. | |
virtual void * | ConvertSubArray (const ScalarDataType dtype, const size_t fromIdx, const size_t len) const |
Convert a sub-array to any given primitive data type. | |
virtual void | ConvertSubArray (void *const destination, const ScalarDataType dtype, const size_t fromIdx, const size_t len) const |
Convert a sub-array to given primitive data type into existing array. | |
virtual void | ChangeEndianness () |
Change endianness of data. | |
virtual void | Rescale (const Types::DataItem scale=1, const Types::DataItem offset=0) |
Scale values in the array. | |
virtual void | RescaleAndShift (const Types::DataItem scale=1, const Types::DataItem offset=0, const size_t shiftBits=0) |
Scale and shift values in the array. | |
virtual void | Rescale (const Types::DataItem scale, const Types::DataItem offset, const Types::DataItem truncLo, const Types::DataItem truncHi=CMTK_ITEM_MAX) |
Scale values in the array with truncation boundaries. | |
virtual void | GammaCorrection (const Types::DataItem gamma) |
Apply gamma correction. | |
virtual void | ApplyFunctionFloat (typename Self::FunctionTypeFloat f) |
Apply real function to data. | |
virtual void | ApplyFunctionDouble (typename Self::FunctionTypeDouble f) |
Apply real function to data. | |
virtual void | Threshold (const Types::DataItemRange &range) |
Threshold data. | |
virtual void | ThresholdToPadding (const Types::DataItemRange &range) |
Threshold data. | |
virtual void | Binarize (const Types::DataItem threshold=0) |
Binarize array values with given threshold. | |
virtual void | MakeAbsolute () |
Convert all values to absolute values. | |
virtual bool | Get (Types::DataItem &value, const size_t index) const |
Get an item from the array. | |
virtual void | GetSequence (Types::DataItem *const values, const size_t index, const size_t length) const |
Get a sequence of items from the array. | |
virtual void | Set (const Types::DataItem value, const size_t index) |
Set an item in the array. | |
virtual void * | GetPaddingPtr () const |
Return padding data value as pointer to native representation. | |
virtual Types::DataItem | GetPaddingValue () const |
Return padding data value as pointer to native representation. | |
virtual bool | PaddingDataAt (const size_t index) const |
Test if there is PADDING data at a particular location. | |
virtual Types::DataItem * | GetData () const |
Get the whole array data as an exchange type array. | |
virtual void | SetData (Types::DataItem *const data) |
Set all data from an Types::DataItem array. | |
virtual void | ClearArray (const bool usePaddingData=false) |
Clear entire array. | |
virtual const Types::DataItemRange | GetRange () const |
Calculate minimum and maximum data value. | |
virtual const Types::Range< T > | GetRangeTemplate () const |
Calculate minimum and maximum data value. | |
virtual double | GetEntropy (const bool fractional=CMTK_HISTOGRAM_DISCRETE, const int numberOfBins=128) const |
Calculate entropy of distribution of values in this array. | |
virtual double | GetEntropy (Histogram< unsigned int > &histogram) const |
Calculate entropy of values in this array using existing histogram. | |
virtual double | GetEntropy (Histogram< double > &histogram, const bool fractional=CMTK_HISTOGRAM_DISCRETE) const |
Calculate entropy of values in this array using existing histogram. | |
virtual double | GetEntropy (Histogram< double > &histogram, const double *kernel, const size_t kernelRadius) const |
Calculate entropy of values in this array using existing histogram and kernel for Parzen windowing. | |
virtual size_t | GetStatistics (Types::DataItem &mean, Types::DataItem &variance) const |
Calculate statistics. | |
virtual void | BlockSet (const Types::DataItem value, const size_t fromOffset, const size_t toOffset) |
Set data block to constant value. | |
virtual Histogram< unsigned int >::SmartPtr | GetHistogram (const unsigned int numberOfBins, const bool centeredBins=false) const |
Get data histogram. | |
virtual void | ApplyFunctionObject (const TypedArrayFunction &f) |
Apply function class to the values of this array. | |
Static Public Member Functions | |
static Self::SmartPtr | Create (const size_t size) |
Create array of this type. | |
Protected Member Functions | |
virtual Self * | CloneVirtual () const |
Clone this object. | |
Private Member Functions | |
virtual void | Alloc (const size_t datasize) |
Allocate data array. | |
virtual void | FreeData () |
De-allocate data array. | |
Private Attributes | |
T * | Data |
The acutal data array. | |
T | Padding |
Value used for missing data. |
Template for Variable-Typed Data Arrays.
From this object, various children are derived for the concrete data types to be handled.
Definition at line 56 of file cmtkTemplateArray.h.
typedef TemplateArray<T> cmtk::TemplateArray< T >::Self |
typedef SmartPointer<Self> cmtk::TemplateArray< T >::SmartPtr |
Smart pointer.
Reimplemented from cmtk::TypedArray.
Definition at line 68 of file cmtkTemplateArray.h.
typedef TypedArray cmtk::TemplateArray< T >::Superclass |
Base class.
Definition at line 65 of file cmtkTemplateArray.h.
typedef DataTypeTraits<T> cmtk::TemplateArray< T >::TypeTraits |
Data type traits.
Definition at line 71 of file cmtkTemplateArray.h.
cmtk::TemplateArray< T >::TemplateArray | ( | void *const | data, |
const size_t | datasize, | ||
const bool | freeArray, | ||
const bool | paddingflag, | ||
const void * | paddingData | ||
) | [inline] |
Constructor.
A typed array is built from an existing array.
data | Pointer to the array of values to be stored. |
datasize | Number of elements in the data array. |
freeArray | Tag of the memory handler that has to be used for freeing the array after use. |
paddingflag | Flag that indicates whether there are missing elements in the existing data array. |
paddingData | Value that marks missing elements in the data array if "paddingFlag" is true. |
Definition at line 102 of file cmtkTemplateArray.h.
cmtk::TemplateArray< T >::TemplateArray | ( | const size_t | datasize = 0 ) |
[inline] |
Constructor.
Allocate an array of a given size.
Definition at line 118 of file cmtkTemplateArray.h.
References NULL.
virtual cmtk::TemplateArray< T >::~TemplateArray | ( | ) | [inline, virtual] |
Destructor.
Free memory by a call to FreeData().
Definition at line 128 of file cmtkTemplateArray.h.
virtual void cmtk::TemplateArray< T >::Alloc | ( | const size_t | datasize ) | [inline, private, virtual] |
Allocate data array.
datasize | Number of data items to allocate memory for. |
Implements cmtk::TypedArray.
Definition at line 609 of file cmtkTemplateArray.h.
References cmtk::Memory::DeleteArray(), and NULL.
virtual void cmtk::TemplateArray< T >::Binarize | ( | const Types::DataItem | threshold = 0 ) |
[inline, virtual] |
Binarize array values with given threshold.
All values greater than threshold (default: zero) are set to one, all values smaller or equal are set to zero.
Implements cmtk::TypedArray.
Definition at line 408 of file cmtkTemplateArray.h.
virtual void cmtk::TemplateArray< T >::ClearArray | ( | const bool | usePaddingData = false ) |
[inline, virtual] |
Clear entire array.
usePaddingData | If this flag is set, then the array will be filled with the PaddingData value, if one exists. Otherwise, the array will be filled with the respective data type's zero value. |
Implements cmtk::TypedArray.
Definition at line 541 of file cmtkTemplateArray.h.
virtual Self* cmtk::TemplateArray< T >::CloneVirtual | ( | ) | const [inline, protected, virtual] |
Clone this object.
Implements cmtk::TypedArray.
Definition at line 589 of file cmtkTemplateArray.h.
References cmtk::TemplateArray< T >::Data, cmtk::TemplateArray< T >::Padding, and cmtk::TypedArray::PaddingFlag.
virtual T cmtk::TemplateArray< T >::ConvertItem | ( | const Types::DataItem | value ) | [inline, virtual] |
Convert Types::DataItem to template type.
This function takes an Types::DataItem value and converts it into a value of the type stored in this array.
value | The item in Types::DataItem representation. |
Definition at line 273 of file cmtkTemplateArray.h.
static Self::SmartPtr cmtk::TemplateArray< T >::Create | ( | const size_t | size ) | [inline, static] |
Create array of this type.
Definition at line 74 of file cmtkTemplateArray.h.
Referenced by cmtk::EntropyMinimizationIntensityCorrectionFunctionalBase::SetInputImage().
virtual void cmtk::TemplateArray< T >::FreeData | ( | ) | [inline, private, virtual] |
De-allocate data array.
The array is freed using the same memory handler that allocated it. In any case, the current Data pointer is set to NULL.
Implements cmtk::TypedArray.
Definition at line 636 of file cmtkTemplateArray.h.
References cmtk::Memory::DeleteArray(), and NULL.
virtual bool cmtk::TemplateArray< T >::Get | ( | Types::DataItem & | value, |
const size_t | index | ||
) | const [inline, virtual] |
Get an item from the array.
value | The variable referenced by this parameter is set to the data item stored at the given location in the array. If this item is marked is "padding data", ie. non-existent, "value" is set to zero. |
index | The index of the item to retrieve. Valid values are in the range [0..Datasize()-1]. |
Implements cmtk::TypedArray.
Definition at line 442 of file cmtkTemplateArray.h.
References CheckBounds.
virtual Types::DataItem* cmtk::TemplateArray< T >::GetData | ( | ) | const [inline, virtual] |
Get the whole array data as an exchange type array.
Implements cmtk::TypedArray.
Definition at line 511 of file cmtkTemplateArray.h.
virtual void* cmtk::TemplateArray< T >::GetDataPtr | ( | const size_t | offset = 0 ) |
[inline, virtual] |
Return pointer to an element in this objects data array.
Implements cmtk::TypedArray.
Definition at line 191 of file cmtkTemplateArray.h.
virtual const void* cmtk::TemplateArray< T >::GetDataPtr | ( | const size_t | offset = 0 ) |
const [inline, virtual] |
Return const pointer to an element in this objects data array.
Implements cmtk::TypedArray.
Definition at line 197 of file cmtkTemplateArray.h.
const T* cmtk::TemplateArray< T >::GetDataPtrConcrete | ( | ) | const [inline] |
Return const pointer to actual data.
Definition at line 80 of file cmtkTemplateArray.h.
T* cmtk::TemplateArray< T >::GetDataPtrConcrete | ( | ) | [inline] |
Return pointer to actual data.
Definition at line 83 of file cmtkTemplateArray.h.
virtual const T* cmtk::TemplateArray< T >::GetDataPtrTemplate | ( | const size_t | offset = 0 ) |
const [inline, virtual] |
Return const pointer to an element in this objects data array.
Definition at line 209 of file cmtkTemplateArray.h.
virtual T* cmtk::TemplateArray< T >::GetDataPtrTemplate | ( | const size_t | offset = 0 ) |
[inline, virtual] |
Return pointer to an element in this objects data array.
Definition at line 203 of file cmtkTemplateArray.h.
virtual size_t cmtk::TemplateArray< T >::GetItemSize | ( | ) | const [inline, virtual] |
Return size in bytes of the primitive data type handled by this object.
Implements cmtk::TypedArray.
Definition at line 188 of file cmtkTemplateArray.h.
virtual void* cmtk::TemplateArray< T >::GetPaddingPtr | ( | ) | const [inline, virtual] |
Return padding data value as pointer to native representation.
This function returns a pointer to the value used by this object for marking non-existent data. As the type of this value depends on the template parameters of this class, only a void pointer can be returned. The caller has to interpret the value stored at that location itself.
If this array does NOT have a padding data value, the data pointed to by the result of this function is undefined.
Implements cmtk::TypedArray.
Definition at line 493 of file cmtkTemplateArray.h.
virtual Types::DataItem cmtk::TemplateArray< T >::GetPaddingValue | ( | ) | const [inline, virtual] |
Return padding data value as pointer to native representation.
Implements cmtk::TypedArray.
Definition at line 497 of file cmtkTemplateArray.h.
virtual void cmtk::TemplateArray< T >::GetSequence | ( | Types::DataItem *const | values, |
const size_t | index, | ||
const size_t | length | ||
) | const [inline, virtual] |
Get a sequence of items from the array.
values | This must point to an allocated array of at least as many Types::DataItem objects as given in the "length" parameter. |
index | The index of the item to retrieve. Valid values are in the range [0..Datasize()-1]. |
length | Number of consecutive values to get. |
Implements cmtk::TypedArray.
Definition at line 461 of file cmtkTemplateArray.h.
References CheckBounds.
virtual Types::DataItem* cmtk::TemplateArray< T >::GetSubArray | ( | Types::DataItem *const | toPtr, |
const size_t | fromIdx, | ||
const size_t | len, | ||
const Types::DataItem | substPadding = 0 |
||
) | const [inline, virtual] |
Convert and copy continuous sub-array to a given destination.
toPtr | A pointer to the location where the data shall be stored. |
fromIdx | The index of the first copied data item in the array, beginning with 0. |
len | Length, ie. number of values, to copy. The calling function must take care that there is enough memory pointed to by toPtr to store this many values of the transfer data type. |
substPadding | Where there is padding data in the copied range, this value is put to the output. |
Implements cmtk::TypedArray.
Definition at line 225 of file cmtkTemplateArray.h.
virtual Types::DataItem* cmtk::TemplateArray< T >::GetSubArray | ( | const size_t | fromIdx, |
const size_t | len, | ||
const Types::DataItem | substPadding = 0 |
||
) | const [inline, virtual] |
Return a sub array of the current instance.
The data is returned in a newly allocated primitive array of the Types::DataItem data exchange type.
fromIdx | Copying starts at this index in the array. The range for this parameter is [0..Size-1]. |
len | Number of data elements to be copied. |
substPadding | If this flag is set (default is NO), then during copying all elements marked as "non-existent" are replaced by zero. |
Implements cmtk::TypedArray.
Definition at line 259 of file cmtkTemplateArray.h.
virtual ScalarDataType cmtk::TemplateArray< T >::GetType | ( | ) | const [inline, virtual] |
Return id of primitive data type handled by this object.
Implements cmtk::TypedArray.
Definition at line 185 of file cmtkTemplateArray.h.
virtual bool cmtk::TemplateArray< T >::IsPaddingAt | ( | const size_t | index ) | const [inline, virtual] |
Check for NULL data at given index.
If this array does not have PaddingFlag set, the result is always false.
Implements cmtk::TypedArray.
Definition at line 162 of file cmtkTemplateArray.h.
virtual bool cmtk::TemplateArray< T >::IsPaddingOrZeroAt | ( | const size_t | index ) | const [inline, virtual] |
Check for PADDING data or zero value at given index.
Implements cmtk::TypedArray.
Definition at line 169 of file cmtkTemplateArray.h.
virtual void cmtk::TemplateArray< T >::MakeAbsolute | ( | ) | [inline, virtual] |
Convert all values to absolute values.
Implements cmtk::TypedArray.
Definition at line 425 of file cmtkTemplateArray.h.
References cmtk::Wrappers::Abs().
virtual bool cmtk::TemplateArray< T >::PaddingDataAt | ( | const size_t | index ) | const [inline, virtual] |
Test if there is PADDING data at a particular location.
Implements cmtk::TypedArray.
Definition at line 500 of file cmtkTemplateArray.h.
virtual void cmtk::TemplateArray< T >::ReplacePaddingData | ( | const Types::DataItem | value = 0 ) |
[inline, virtual] |
Replace Padding data (padding) with given value.
Implements cmtk::TypedArray.
Definition at line 146 of file cmtkTemplateArray.h.
virtual void cmtk::TemplateArray< T >::Rescale | ( | const Types::DataItem | scale = 1 , |
const Types::DataItem | offset = 0 |
||
) | [inline, virtual] |
Scale values in the array.
A call to this member function will perform an in-place rescaling of the values in the array.
scale | The original data value is multiplied by the parameter first. |
offset | This value is added to the original data value after multiplying it by the scale parameter. |
Implements cmtk::TypedArray.
Definition at line 305 of file cmtkTemplateArray.h.
virtual void cmtk::TemplateArray< T >::Rescale | ( | const Types::DataItem | scale, |
const Types::DataItem | offset, | ||
const Types::DataItem | truncLo, | ||
const Types::DataItem | truncHi = CMTK_ITEM_MAX |
||
) | [inline, virtual] |
Scale values in the array with truncation boundaries.
A call to this member function will perform an in-place rescaling of the values in the array with value range truncation. Truncation takes place after the scaling itself, i.e., the truncation boundaries refer to the already scaled values.
scale | The original data value is multiplied by the parameter first. |
offset | This value is added to the original data value after multiplying it by the scale parameter. |
truncLo | Lower truncation boundary. Scaled items below this threshold will be set to equal its value. |
truncHi | Upper truncation boundary. Scaled items above this threshold will be set to equal its value. |
Implements cmtk::TypedArray.
Definition at line 339 of file cmtkTemplateArray.h.
virtual void cmtk::TemplateArray< T >::RescaleAndShift | ( | const Types::DataItem | scale = 1 , |
const Types::DataItem | offset = 0 , |
||
const size_t | shiftBits = 0 |
||
) | [inline, virtual] |
Scale and shift values in the array.
Data values are scaled first, then the offsewt is added, and finally the (left) bit shift is applied. In fact, to make sure we're not messing up floats, the bit shift is applied as a multiplication.
Implements cmtk::TypedArray.
Definition at line 317 of file cmtkTemplateArray.h.
virtual void cmtk::TemplateArray< T >::Set | ( | const Types::DataItem | value, |
const size_t | index | ||
) | [inline, virtual] |
Set an item in the array.
value | The new value for the specified item. |
index | The index of the item to set. Valid values are in the range [0..Datasize()-1]. |
Implements cmtk::TypedArray.
Definition at line 477 of file cmtkTemplateArray.h.
References CheckBounds.
virtual void cmtk::TemplateArray< T >::SetData | ( | Types::DataItem *const | data ) | [inline, virtual] |
Set all data from an Types::DataItem array.
This function sets all values stored in the present array from a memory region with Types::DataItem values.
data | Pointer to an array of Types::DataItem values. Control over the source array is not taken by this object. If it is on the heap, then the calling routine remains responsible for de-allocating the array afterwards. |
Implements cmtk::TypedArray.
Definition at line 529 of file cmtkTemplateArray.h.
virtual void cmtk::TemplateArray< T >::SetPaddingAt | ( | const size_t | size_t = 0 ) |
[inline, virtual] |
Set the specified array element to no data present.
Implements cmtk::TypedArray.
Definition at line 174 of file cmtkTemplateArray.h.
virtual void cmtk::TemplateArray< T >::SetPaddingPtr | ( | const void * | paddingData ) | [inline, virtual] |
Set the value to mark non-existent data using interface data type.
Implements cmtk::TypedArray.
Definition at line 140 of file cmtkTemplateArray.h.
virtual void cmtk::TemplateArray< T >::SetPaddingValue | ( | const Types::DataItem | paddingData ) | [inline, virtual] |
Set the value to mark non-existent data using interface data type.
Implements cmtk::TypedArray.
Definition at line 134 of file cmtkTemplateArray.h.
void cmtk::TemplateArray< T >::SetPaddingValueTemplate | ( | const T | paddingData ) | [inline] |
Set the value to mark non-existent data using template data type.
Definition at line 86 of file cmtkTemplateArray.h.
virtual void cmtk::TemplateArray< T >::Threshold | ( | const Types::DataItemRange & | range ) | [inline, virtual] |
Threshold data.
All values above upper threshold are set to upper thrershold. All values below lower threshold are set to lower threshold.
Implements cmtk::TypedArray.
Definition at line 371 of file cmtkTemplateArray.h.
References cmtk::Types::Range< T >::m_LowerBound, and cmtk::Types::Range< T >::m_UpperBound.
virtual void cmtk::TemplateArray< T >::ThresholdToPadding | ( | const Types::DataItemRange & | range ) | [inline, virtual] |
Threshold data.
All values outside the threshold range are set to the Padding (padding) value.
Implements cmtk::TypedArray.
Definition at line 391 of file cmtkTemplateArray.h.
References cmtk::Types::Range< T >::m_LowerBound, and cmtk::Types::Range< T >::m_UpperBound.
T* cmtk::TemplateArray< T >::Data [private] |
The acutal data array.
Definition at line 601 of file cmtkTemplateArray.h.
Referenced by cmtk::TemplateArray< T >::CloneVirtual().
T cmtk::TemplateArray< T >::Padding [private] |
Value used for missing data.
Definition at line 604 of file cmtkTemplateArray.h.
Referenced by cmtk::TemplateArray< T >::CloneVirtual().