aimsalgo 6.0.0
Neuroimaging image processing
splinesubsampler_d.h
Go to the documentation of this file.
1/* This software and supporting documentation are distributed by
2 * Institut Federatif de Recherche 49
3 * CEA/NeuroSpin, Batiment 145,
4 * 91191 Gif-sur-Yvette cedex
5 * France
6 *
7 * This software is governed by the CeCILL-B license under
8 * French law and abiding by the rules of distribution of free software.
9 * You can use, modify and/or redistribute the software under the
10 * terms of the CeCILL-B license as circulated by CEA, CNRS
11 * and INRIA at the following URL "http://www.cecill.info".
12 *
13 * As a counterpart to the access to the source code and rights to copy,
14 * modify and redistribute granted by the license, users are provided only
15 * with a limited warranty and the software's author, the holder of the
16 * economic rights, and the successive licensors have only limited
17 * liability.
18 *
19 * In this respect, the user's attention is drawn to the risks associated
20 * with loading, using, modifying and/or developing or reproducing the
21 * software by the user in light of its specific status of free software,
22 * that may mean that it is complicated to manipulate, and that also
23 * therefore means that it is reserved for developers and experienced
24 * professionals having in-depth computer knowledge. Users are therefore
25 * encouraged to load and test the software's suitability as regards their
26 * requirements in conditions enabling the security of their systems and/or
27 * data to be ensured and, more generally, to use and operate it in the
28 * same conditions as regards security.
29 *
30 * The fact that you are presently reading this means that you have had
31 * knowledge of the CeCILL-B license and that you accept its terms.
32 */
33
34#ifndef AIMS_PYRAMID_SPLINESUBSAMPLER_D_H
35#define AIMS_PYRAMID_SPLINESUBSAMPLER_D_H
36
37//--- aims -------------------------------------------------------------------
39#include <aims/pyramid/convolutionsubsampler_d.h> // aims::ConvolutionSubSampler
40#include <aims/math/bspline.h> // aims::TabulBSpline
41#include <aims/resampling/splineresampler.h> // aims::mirrorCoeff
42#include <aims/utility/progress.h> // aims::Progression
43//--- cartobase --------------------------------------------------------------
44#include <cartobase/config/verbose.h> // carto::verbose
45//--- std --------------------------------------------------------------------
46#include <cmath> // std::ceil/floor/isfinite/NAN
47#include <vector>
48#include <iostream>
49//----------------------------------------------------------------------------
50
51namespace aims {
52
53 //--------------------------------------------------------------------------
54 // CONSTRUCTORS
55 //--------------------------------------------------------------------------
56
58 bool normalize,
59 unsigned n ):
62 {
63 setFunctions( Point4du( r, r, r, r ), n );
64 }
65
74
77
82
85 {
86 if( this != &other )
87 {
89 _normalize = other._normalize;
90 }
91 return *this;
92 }
93
94 //--------------------------------------------------------------------------
95 // PARAMETERS
96 //--------------------------------------------------------------------------
97
99 {
100 return this->_func[0].order();
101 }
102
104 {
105 return _normalize;
106 }
107
109 {
110 for( std::vector<DiscreteBSpline>::iterator f = this->_func.begin();
111 f != this->_func.end(); ++f )
112 f->setOrder( n );
113 }
114
119
121 {
123 for( std::vector<DiscreteBSpline>::iterator f = this->_func.begin();
124 f != this->_func.end(); ++f )
125 f->setScale( (float)r );
126 }
127
129 {
131 int i = 0;
132 for( std::vector<DiscreteBSpline>::iterator f = this->_func.begin();
133 f != this->_func.end(); ++f, ++i )
134 f->setScale( (float)r[i] );
135 }
136
137 //--------------------------------------------------------------------------
138 // HELPER
139 //--------------------------------------------------------------------------
140
142 {
143 std::vector<DiscreteBSpline> f;
144 f.reserve( 4 );
145 f.push_back( DiscreteBSpline( n, (float)r[0] ) );
146 f.push_back( DiscreteBSpline( n, (float)r[1] ) );
147 f.push_back( DiscreteBSpline( n, (float)r[2] ) );
148 f.push_back( DiscreteBSpline( n, (float)r[3] ) );
150 }
151
152 //--------------------------------------------------------------------------
153 // Execution
154 //--------------------------------------------------------------------------
155
156 template <typename OUT, typename IN>
158 const carto::VolumeRef<IN> & in, carto::VolumeRef<OUT> & out ) const
159 {
161 std::vector<int> size = in.getSize();
162 double div = 1;
163 for( std::size_t i = 0; i < 4; ++i )
164 if( this->_dir[i] && size[i] > 1 )
165 div *= ( this->_func.size() > i ? this->_func[i].scale()
166 : this->_func[0].scale() );
167 out /= div;
168 return out;
169 }
170
171} // namespace aims
172
173#endif // AIMS_PYRAMID_SPLINESUBSAMPLER_D_H
carto::VolumeRef< OUT > execute(const carto::VolumeRef< IN > &in) const
Execution.
void setBasisFunction(const BasisFunction &func)
ConvolutionSubSampler & operator=(const ConvolutionSubSampler &other)
Class excuting a spline-based subsampling.
void setFactor(unsigned r)
Override ConclutionSubSampler version to update the underlying basis functions.
void setFunctions(const Point4du &r, unsigned n)
carto::VolumeRef< OUT > execute(const carto::VolumeRef< IN > &in, carto::VolumeRef< OUT > &out) const
Execution.
void setNormalize(bool normalize=true)
Set normalization mode.
void setOrder(unsigned n)
Set spline order Updates underlying basis functions.
DirectBSplineSubSampler(unsigned factor=2, bool normalize=false, unsigned spline_order=3)
Constructor / Copy.
bool normalize() const
Get normalization mode.
DirectBSplineSubSampler & operator=(const DirectBSplineSubSampler &other)
unsigned order() const
Parameters.
Discrete B-Splines B-Spline pre sampled only on integral values.
Definition bspline.h:326
std::vector< int > getSize() const
AimsVector< uint32_t, 4 > Point4du