diff 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
line wrap: on
line diff
--- a/base/ColumnOp.h	Tue Feb 28 11:26:24 2017 +0000
+++ b/base/ColumnOp.h	Tue Feb 28 14:04:16 2017 +0000
@@ -26,6 +26,9 @@
  * Max1 means to normalize to max value = 1.0.
  * Sum1 means to normalize to sum of values = 1.0.
  *
+ * Range01 means to normalize such that the max value = 1.0 and the
+ * min value (if different from the max value) = 0.0.
+ *
  * Hybrid means normalize to max = 1.0 and then multiply by
  * log10 of the max value, to retain some difference between
  * levels of neighbouring columns.
@@ -36,6 +39,7 @@
     None,
     Max1,
     Sum1,
+    Range01,
     Hybrid
 };
 
@@ -63,6 +67,17 @@
     }
 
     /**
+     * Shift the values in the given column by the given offset.
+     */
+    static Column applyShift(const Column &in, float offset) {
+        if (offset == 0.f) return in;
+	Column out;
+	out.reserve(in.size());
+	for (auto v: in) out.push_back(v + offset);
+	return out;
+    }
+
+    /**
      * Scale an FFT output downward by half the FFT size.
      */
     static Column fftScale(const Column &in, int fftSize);