Mercurial > hg > svcore
comparison base/ColumnOp.h @ 1527:710e6250a401 zoom
Merge from default branch
author | Chris Cannam |
---|---|
date | Mon, 17 Sep 2018 13:51:14 +0100 |
parents | 48e9f538e6e9 |
children | 1b688ab5f1b3 |
comparison
equal
deleted
inserted
replaced
1324:d4a28d1479a8 | 1527:710e6250a401 |
---|---|
24 * Display normalization types for columns in e.g. grid plots. | 24 * Display normalization types for columns in e.g. grid plots. |
25 * | 25 * |
26 * Max1 means to normalize to max value = 1.0. | 26 * Max1 means to normalize to max value = 1.0. |
27 * Sum1 means to normalize to sum of values = 1.0. | 27 * Sum1 means to normalize to sum of values = 1.0. |
28 * | 28 * |
29 * Range01 means to normalize such that the max value = 1.0 and the | |
30 * min value (if different from the max value) = 0.0. | |
31 * | |
29 * Hybrid means normalize to max = 1.0 and then multiply by | 32 * Hybrid means normalize to max = 1.0 and then multiply by |
30 * log10 of the max value, to retain some difference between | 33 * log10 of the max value, to retain some difference between |
31 * levels of neighbouring columns. | 34 * levels of neighbouring columns. |
32 * | 35 * |
33 * Area normalization is handled separately. | 36 * Area normalization is handled separately. |
34 */ | 37 */ |
35 enum class ColumnNormalization { | 38 enum class ColumnNormalization { |
36 None, | 39 None, |
37 Max1, | 40 Max1, |
38 Sum1, | 41 Sum1, |
42 Range01, | |
39 Hybrid | 43 Hybrid |
40 }; | 44 }; |
41 | 45 |
42 /** | 46 /** |
43 * Class containing static functions for simple operations on data | 47 * Class containing static functions for simple operations on data |
54 /** | 58 /** |
55 * Scale the given column using the given gain multiplier. | 59 * Scale the given column using the given gain multiplier. |
56 */ | 60 */ |
57 static Column applyGain(const Column &in, double gain) { | 61 static Column applyGain(const Column &in, double gain) { |
58 if (gain == 1.0) return in; | 62 if (gain == 1.0) return in; |
59 Column out; | 63 Column out; |
60 out.reserve(in.size()); | 64 out.reserve(in.size()); |
61 for (auto v: in) out.push_back(float(v * gain)); | 65 for (auto v: in) out.push_back(float(v * gain)); |
62 return out; | 66 return out; |
67 } | |
68 | |
69 /** | |
70 * Shift the values in the given column by the given offset. | |
71 */ | |
72 static Column applyShift(const Column &in, float offset) { | |
73 if (offset == 0.f) return in; | |
74 Column out; | |
75 out.reserve(in.size()); | |
76 for (auto v: in) out.push_back(v + offset); | |
77 return out; | |
63 } | 78 } |
64 | 79 |
65 /** | 80 /** |
66 * Scale an FFT output downward by half the FFT size. | 81 * Scale an FFT output downward by half the FFT size. |
67 */ | 82 */ |
78 return in[0] >= in[1]; | 93 return in[0] >= in[1]; |
79 } | 94 } |
80 if (!in_range_for(in, ix+1)) { | 95 if (!in_range_for(in, ix+1)) { |
81 return in[ix] > in[ix-1]; | 96 return in[ix] > in[ix-1]; |
82 } | 97 } |
83 if (in[ix] < in[ix+1]) { | 98 if (in[ix] < in[ix+1]) { |
84 return false; | 99 return false; |
85 } | 100 } |
86 if (in[ix] <= in[ix-1]) { | 101 if (in[ix] <= in[ix-1]) { |
87 return false; | 102 return false; |
88 } | 103 } |
89 return true; | 104 return true; |
90 } | 105 } |
91 | 106 |
92 /** | 107 /** |
93 * Return a column containing only the local peak values (all | 108 * Return a column containing only the local peak values (all |
94 * others zero). | 109 * others zero). |
113 * source column ("in") may be a partial column; it's assumed to | 128 * source column ("in") may be a partial column; it's assumed to |
114 * contain enough bins to span the destination range, starting | 129 * contain enough bins to span the destination range, starting |
115 * with the bin of index minbin. | 130 * with the bin of index minbin. |
116 */ | 131 */ |
117 static Column distribute(const Column &in, | 132 static Column distribute(const Column &in, |
118 int h, | 133 int h, |
119 const std::vector<double> &binfory, | 134 const std::vector<double> &binfory, |
120 int minbin, | 135 int minbin, |
121 bool interpolate); | 136 bool interpolate); |
122 | 137 |
123 }; | 138 }; |
124 | 139 |
125 #endif | 140 #endif |
126 | 141 |