-
Notifications
You must be signed in to change notification settings - Fork 177
/
resample.h
121 lines (76 loc) · 2.6 KB
/
resample.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*
* Copyright (c) 2008-2016 the MRtrix3 contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/
*
* MRtrix is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* For more details, see www.mrtrix.org
*
*/
#ifndef __dwi_tractography_resample_h__
#define __dwi_tractography_resample_h__
#include <vector>
#include "dwi/tractography/tracking/generated_track.h"
namespace MR {
namespace DWI {
namespace Tractography {
class Upsampler
{
public:
Upsampler () :
data (4, 3) { }
Upsampler (const size_t os_ratio) :
data (4, 3) {
set_ratio (os_ratio);
}
Upsampler (const Upsampler& that) :
M (that.M),
temp (M.rows(), 3),
data (4, 3) { }
~Upsampler() { }
void set_ratio (const size_t);
bool operator() (std::vector<Eigen::Vector3f>&) const;
size_t get_ratio() const { return (M.rows() ? (M.rows() + 1) : 1); }
bool valid () const { return (M.rows()); }
private:
Eigen::MatrixXf M;
mutable Eigen::MatrixXf temp, data;
bool interp_prepare (std::vector<Eigen::Vector3f>&) const;
void increment (const Eigen::Vector3f&) const;
};
class Downsampler
{
public:
Downsampler () : ratio (1) { }
Downsampler (const size_t downsample_ratio) : ratio (downsample_ratio) { }
bool operator() (Tracking::GeneratedTrack&) const;
bool operator() (std::vector<Eigen::Vector3f>&) const;
bool valid() const { return (ratio > 1); }
size_t get_ratio() const { return ratio; }
void set_ratio (const size_t i) { ratio = i; }
private:
size_t ratio;
};
class Resampler
{
public:
Resampler () :
step_size (0.0) { }
Resampler (const float ss) :
step_size (ss) { }
void set_step_size (const float ss) { step_size = ss; }
float get_step_size() const { return step_size; }
bool valid() const { return step_size; }
bool operator() (std::vector<Eigen::Vector3f>&) const;
private:
float step_size;
};
}
}
}
#endif