changeset 101:ff383bfee463

* Add local normalisation to adaptive spectrogram
author Chris Cannam <c.cannam@qmul.ac.uk>
date Tue, 12 May 2009 10:27:03 +0000
parents bae940a2ff18
children a861016f4811
files plugins/AdaptiveSpectrogram.cpp
diffstat 1 files changed, 15 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/AdaptiveSpectrogram.cpp	Mon Apr 27 15:30:05 2009 +0000
+++ b/plugins/AdaptiveSpectrogram.cpp	Tue May 12 10:27:03 2009 +0000
@@ -361,8 +361,10 @@
 
     int minwid = (2 << m_w), maxwid = ((2 << m_w) << m_n);
 
+#ifdef DEBUG_VERBOSE
     cerr << "widths from " << minwid << " to " << maxwid << " ("
          << minwid/2 << " to " << maxwid/2 << " in real parts)" << endl;
+#endif
 
     Spectrograms s(minwid/2, maxwid/2, 1);
     
@@ -395,7 +397,9 @@
 
     Cutting *cutting = cut(s, maxwid/2, 0, 0, maxwid/2);
 
+#ifdef DEBUG_VERBOSE
     printCutting(cutting, "  ");
+#endif
 
     vector<vector<float> > rmat(maxwid/minwid);
     for (int i = 0; i < maxwid/minwid; ++i) {
@@ -459,6 +463,17 @@
         double vcost = top->cost + bottom->cost;
         double hcost = left->cost + right->cost;
 
+        bool normalize = true;
+
+        if (normalize) {
+
+            double venergy = top->value + bottom->value;
+            vcost = (vcost + (venergy * log(venergy))) / venergy;
+
+            double henergy = left->value + right->value;
+            hcost = (hcost + (henergy * log(henergy))) / henergy;
+        }            
+
         if (vcost > hcost) {
 
             // cut horizontally (left/right)