aimsalgo 6.0.0
Neuroimaging image processing
diffusionSmoother.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
35#ifndef AIMS_PRIMALSKETCH_DIFFUSIONSMOOTHER_H
36#define AIMS_PRIMALSKETCH_DIFFUSIONSMOOTHER_H
37
38#include <cstdlib>
40
41namespace aims
42{
43
45template<typename T>
47 : public Smoother<carto::VolumeRef<T>, carto::VolumeRef<T> >
48{
49public:
50 BaseDiffusionSmoother(float delta_t) {this->SetDt(delta_t);}
52public:
53 void check(int maxiter);
54 bool optimal() {return true;}
55 void SetDt(float Delta_t) {
56 if (Delta_t<=0.25) _dt=Delta_t;
57 else {
58 std::cerr << "Diffusion Smoother : dt must be <= 0.25"
59 << std::endl; exit(EXIT_FAILURE);
60 }
61 }
63 int maxiter, bool verbose=false) = 0;
64
65 float dt() {return _dt;}
66
67public:
70
71protected:
72 float _dt;
73};
74
75
78template<typename T>
80{
81public:
82 DiffusionSmoother(float delta_t) : BaseDiffusionSmoother<T>(delta_t),
83 _hasConstantSources( false ) {}
85
86public:
88 int maxiter, bool verbose=false);
89 void setConstantSources( const carto::VolumeRef<T> &, const T & background );
91
92private:
93 carto::VolumeRef<T> _constantSources;
94 bool _hasConstantSources;
95 T _constantSourcesBackground;
96};
97
98
99template<typename T>
101{
102public:
103 BaseMaskedDiffusionSmoother(float delta_t, bool safe=true) :
104 BaseDiffusionSmoother<T>(delta_t), _safe(safe)
105 { _mask.reset( 0 ); }
107
108public:
110 int maxiter, bool verbose=false) = 0;
112 short background=0)
113 {
114 _mask = mask;
115 _background = background;
116 }
117
118protected:
120 bool _safe;
122};
123
124
125
126template<typename T, typename N=std::vector<Point3df> >
128{
129public:
130 MaskedDiffusionSmoother(float delta_t, bool safe=true) :
131 BaseMaskedDiffusionSmoother<T>(delta_t, safe) {}
133
134public:
136 int maxiter, bool verbose=false);
137};
138
148template<typename T>
149class MaskedDiffusionSmoother<T, std::vector<Point3df> > :
151{
152public:
153 MaskedDiffusionSmoother(float delta_t, bool safe=true) :
154 BaseMaskedDiffusionSmoother<T>(delta_t, safe),
155 _has_neumann_condition(false) {}
157
158public:
160 int maxiter, bool verbose=false);
161 void add_neumann_condition(const Point3df &p);
162
163private :
164 void update_neumann_conditions(carto::VolumeRef<float> &ima);
165
166private :
167 bool _has_neumann_condition;
168 std::vector<Point3df> _neumann_conditions;
169};
170
171
172
181template<typename T>
182class MaskedDiffusionSmoother<T, carto::VolumeRef<short> > :
184{
185public:
186 MaskedDiffusionSmoother(float delta_t, bool safe=true) :
187 BaseMaskedDiffusionSmoother<T>(delta_t, safe),
188 _neumann_value(1) {}
190
191public:
193 int maxiter, bool verbose=false);
194 void set_neumann_value(short value) {
195 _neumann_value = value;
196 }
197
198 void convolution(const carto::VolumeRef<float> &ima1,
199 carto::VolumeRef<float> &ima2) const;
200private:
201 short _neumann_value;
202};
203
204}
205
206#endif
static carto::VolumeRef< float > init_laplacian(void)
virtual carto::VolumeRef< T > doSmoothing(const carto::VolumeRef< T > &ima, int maxiter, bool verbose=false)=0
static carto::VolumeRef< float > laplacian
carto::VolumeRef< short > _mask
BaseMaskedDiffusionSmoother(float delta_t, bool safe=true)
void setMask(const carto::rc_ptr< carto::Volume< short > > &mask, short background=0)
virtual carto::VolumeRef< T > doSmoothing(const carto::VolumeRef< T > &ima, int maxiter, bool verbose=false)=0
DiffusionSmoother(float delta_t)
void setConstantSources(const carto::VolumeRef< T > &, const T &background)
virtual carto::VolumeRef< T > doSmoothing(const carto::VolumeRef< T > &ima, int maxiter, bool verbose=false)
carto::VolumeRef< T > doSmoothing(const carto::VolumeRef< T > &ima, int maxiter, bool verbose=false)
MaskedDiffusionSmoother(float delta_t, bool safe=true)
BucketMap< Void > * mask(const BucketMap< Void > &src, const BucketMap< Void > &m, bool intersect=true)
STL namespace.
AimsVector< float, 3 > Point3df