diff maths/MedianFilter.h @ 182:5ec47007b873

Fix handling of NaNs in MedianFilter, & test for it
author Chris Cannam
date Mon, 23 Feb 2015 10:42:54 +0000
parents 783fb5f0e626
children fa407c1d9923
line wrap: on
line diff
--- a/maths/MedianFilter.h	Tue Aug 05 17:12:46 2014 +0100
+++ b/maths/MedianFilter.h	Mon Feb 23 10:42:54 2015 +0000
@@ -48,8 +48,9 @@
 
     void push(T value) {
         if (value != value) {
-            std::cerr << "WARNING: MedianFilter::push: attempt to push NaN" << std::endl;
-            return; // nan
+            std::cerr << "WARNING: MedianFilter::push: attempt to push NaN, pushing zero instead" << std::endl;
+            // we do need to push something, to maintain the filter length
+            value = T();
         }
 	drop(m_frame[0]);
 	const int sz1 = m_size-1;