37#ifndef AIMS_UTILITY_LINEARCOMB_H
38#define AIMS_UTILITY_LINEARCOMB_H
41#include <cartodata/volume/volume.h>
42#include <cartobase/containers/nditerator.h>
73 float num2=0.0,
float den2=1.0)
74 {
ASSERT(den1!=0 && den2!=0);
108 typedef typename std::map<T, T, carto::KeyComparatorLess<T> >
MapType;
128 template <
class T>
inline
133 if( data1->getSize() != data2->getSize() )
134 AimsError(
"VolumeRef<T> AimsLinearCombination(const rc_ptr<Volume<T> > &,\
135 float,float,const rc_ptr<Volume<T> > &,float,float) : \
136 sizes must be the same");
143 it!=comb->
end(); it++, it1++, it2++ )
144 *it = (T)((
double)*it1 * (
double)
_num1 / (
double)
_den1 +
145 (
double)*it2 * (
double)
_num2 / (
double)
_den2 );
150 template <
class T>
inline
158 for( it=comb->
begin(), it1=data1->
begin(); it!=comb->
end(); it++, it1++ )
159 *it = (T)((
double)*it1 * (
double)
_num1 / (
double)
_den1);
165 template <
typename T>
175 std::vector<int> pos;
177 typename aims::Replacer<T>::MapType::const_iterator im, em = repl.end();
179 for( ; !it.
ended(); ++it )
185 ds = &ovol.
at(pos) - dp;
189 im = repl.find( *p );
float _den2
dividor for the second data
float _num1
multiplicator for the first data
float _num2
multiplicator for the second data
AimsLinearCombination(float num1, float den1, float num2=0.0, float den2=1.0)
The programmer should provide at least 2 parameters to the constructor:
virtual ~AimsLinearCombination()
Destructor does nothing.
float _den1
dividor for the first data
carto::VolumeRef< T > operator()(const carto::rc_ptr< carto::Volume< T > > &data1, const carto::rc_ptr< carto::Volume< T > > &data2)
Return the combination of data1 and data2.
std::map< T, T, carto::KeyComparatorLess< T > > MapType
static void replace(const carto::Volume< T > &ivol, carto::Volume< T > &ovol, const aims::Replacer< T >::MapType &repl)
Replace values from "repl" keys, from the input volume ivol, to the correspodinf repl values in the o...
const std::vector< int > & position() const
std::vector< int > getSize() const
void setVoxelSize(float vx, float vy=1., float vz=1., float vt=1.)
std::vector< long > getStrides() const
const T & at(long x, long y=0, long z=0, long t=0) const
std::ptrdiff_t line_length() const
void inc_line_ptr(const T *&p) const
int line_direction() const
AIMSDATA_API void AimsError(const std::string &message) __attribute__((__noreturn__))
Give an error message on display.
The class for EcatSino data write operation.