34 #ifndef AIMS_SIGNALFILTER_SPLINEFILTER_D_H
35 #define AIMS_SIGNALFILTER_SPLINEFILTER_D_H
51 template <
typename OUTP,
typename INP>
56 std::vector<int> size = in.
getSize();
58 for(
int i = 0; i < 4; ++i )
59 if( this->
_dir[i] && size[i] > 1 )
60 div *= ( (int)this->
_func.size() > i ? this->
_func[i].scale()
61 : this->
_func[0].scale() );
86 InverseSmoothingSplineFilter::InverseSmoothingSplineFilter(
float lambda,
unsigned n ):
98 InverseSmoothingSplineFilter::InverseSmoothingSplineFilter(
const InverseSmoothingSplineFilter & other ):
99 IIRFilterBase( other ),
100 _order( other._order ),
102 _causal( other._causal ),
103 _anticausal( other._anticausal ),
104 _symmetric( other._symmetric ),
105 _interpolation( other._interpolation )
109 InverseSmoothingSplineFilter::~InverseSmoothingSplineFilter()
112 InverseSmoothingSplineFilter & InverseSmoothingSplineFilter::operator=(
const InverseSmoothingSplineFilter & other )
117 _order = other._order;
119 _causal = other._causal;
120 _anticausal = other._anticausal;
121 _symmetric = other._symmetric;
122 _interpolation = other._interpolation;
131 const unsigned & InverseSmoothingSplineFilter::order()
const
136 const float & InverseSmoothingSplineFilter::lambda()
const
141 void InverseSmoothingSplineFilter::setOrder(
unsigned n )
147 void InverseSmoothingSplineFilter::setLambda(
float l )
161 void InverseSmoothingSplineFilter::setFilters()
167 _ftype = Interpolation;
173 double tmp2 = tmp1 * std::sqrt( 3. + 144. *
_lambda );
174 double ksi = 1. - 96. *
_lambda + tmp2;
175 double rho = ( tmp1 - 1. - std::sqrt(ksi) ) / tmp1
176 * std::sqrt( ( 48. *
_lambda + tmp2 ) / ksi );
177 double tan_omega = std::sqrt( ( 144. *
_lambda - 1. ) / ksi );
178 double cos_omega = std::sqrt( 1. / ( 1 + tan_omega * tan_omega ) );
179 double b1 = 2. * rho * cos_omega;
180 double b2 = - rho * rho;
181 double gain = 1 - b1 - b2;
182 double delta = 4. * b2 + b1 * b1;
184 std::cout <<
"tmp1 : " << tmp1 << std::endl;
185 std::cout <<
"tmp2 : " << tmp2 << std::endl;
186 std::cout <<
"ksi : " << ksi << std::endl;
187 std::cout <<
"rho : " << rho << std::endl;
188 std::cout <<
"tan_omega : " << tan_omega << std::endl;
189 std::cout <<
"cos_omega : " << cos_omega << std::endl;
190 std::cout <<
"b1 : " << b1 << std::endl;
191 std::cout <<
"b2 : " << b2 << std::endl;
192 std::cout <<
"delta : " << delta << std::endl;
196 std::vector<double> poles;
197 poles.push_back( - ( b1 - std::sqrt( delta ) ) / ( 2. * b2 ) );
198 poles.push_back( - ( b1 + std::sqrt( delta ) ) / ( 2. * b2 ) );
199 std::cout <<
"z1 : " << poles[0] << std::endl;
200 std::cout <<
"z2 : " << poles[1] << std::endl;
201 _symmetric.setPoles( poles );
202 _symmetric.setGain( gain * gain );
203 _ftype = SymRealPole;
207 std::vector<double> coeffs;
208 coeffs.push_back( b1 );
209 coeffs.push_back( b2 );
210 _causal.setCoeffs( coeffs );
211 _causal.setGain( gain );
212 _anticausal.setCoeffs( coeffs );
213 _anticausal.setGain( gain );
214 _ftype = SymComplexPole;
219 throw std::logic_error( std::string(
"InverseSmoothingSplineFilter with") +
221 std::string(
" not implemented yet.") );
230 _interpolation.filter1d( in, out, dir );
233 _symmetric.filter1d( in, out, dir );
236 _causal.filter1d( in, out, dir );
237 _anticausal.filter1d( out, out, dir );
std::vector< DiscreteBSpline > _func
carto::VolumeRef< OUT > execute(const carto::VolumeRef< IN > &in) const
Execution.
carto::VolumeRef< OUTP > execute(const carto::VolumeRef< INP > &in, carto::VolumeRef< OUTP > &out) const
Execution.
IIRFilterBase & operator=(const IIRFilterBase &other)
std::vector< int > getSize() const
std::string toString(const T &object)