Mercurial > hg > svcore
comparison base/ColumnOp.h @ 1394:9ef1cc26024c
Add Range01 normalisation method to ColumnOp. This is the normalisation that is actually used in the Colour 3D Plot layer historically when column normalisation is enabled (not Max1 after all).
author | Chris Cannam |
---|---|
date | Tue, 28 Feb 2017 14:04:16 +0000 |
parents | dd190086db73 |
children | 48e9f538e6e9 |
comparison
equal
deleted
inserted
replaced
1393:04abe8f73b22 | 1394:9ef1cc26024c |
---|---|
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 |
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)); |
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); | |
62 return out; | 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. |