瀏覽代碼

Added Histogram smoothing.

Daniel Kauth 11 年之前
父節點
當前提交
ab6de0377a

+ 1 - 1
bbiwarg/Graphics/Output2D.cs

@@ -82,7 +82,7 @@ namespace bbiwarg.Graphics
 
             // draw histogram
             GL.Disable(EnableCap.Texture2D);
-            int[] histogram = videoHandle.getHistogram();
+            int[] histogram = videoHandle.getSmoothedHistogram();
             int maxValue = 0;
             for (int i = 0; i < histogram.Length; ++i)
             {

+ 14 - 2
bbiwarg/Images/DepthImage.cs

@@ -71,7 +71,7 @@ namespace bbiwarg.Images
             }
         }
 
-        public int[] getHistogram()
+        public int[] getSmoothedHistogram()
         {
             Int16 minDepth = getMinDepth();
             Int16 maxDepth = getMaxDepth();
@@ -86,10 +86,22 @@ namespace bbiwarg.Images
                         histogram[depth - minDepth]++;
                 }
             }
-            
+
+            smoothHistogram();
             return histogram;
         }
 
+        private void smoothHistogram()
+        {
+            histogram[0] = (histogram[0] + histogram[1]) / 2;
+            histogram[histogram.Length - 1] = (histogram[histogram.Length - 2] + histogram[histogram.Length - 1]) / 2;
+
+            for (int i = 1; i < histogram.Length - 1; ++i)
+            {
+                histogram[i] = (histogram[i - 1] + histogram[i] + histogram[i + 1]) / 3;
+            }
+        }
+
         public Int16 getPeakDepth()
         {
             Int16 minDepth = getMinDepth();

+ 1 - 1
bbiwarg/Main/OutputTest.cs

@@ -13,7 +13,7 @@ namespace bbiwarg.Main
     {
         static void Main(string[] args)
         {
-            IInputProvider inputProvider = new IisuInputProvider("..\\..\\videos\\1.skv");
+            IInputProvider inputProvider = new IisuInputProvider("..\\..\\videos\\touch\\3.skv");
             IVideoHandle videoHandle = new VideoHandle(inputProvider);
 
             Output2D output = new Output2D(videoHandle);

+ 1 - 1
bbiwarg/VideoHandle/IVideoHandle.cs

@@ -34,6 +34,6 @@ namespace bbiwarg.VideoHandles
         int getHeight();
 
         Int16 getPeakDepth();
-        int[] getHistogram();
+        int[] getSmoothedHistogram();
     }
 }

+ 3 - 3
bbiwarg/VideoHandle/VideoHandle.cs

@@ -82,9 +82,9 @@ namespace bbiwarg.VideoHandles
 
             handImage.filterMedian(3);
             int minDepth = handImage.getMinDepth();
-            handImage.thresholdDepth(minDepth, minDepth + 100);
+            handImage.thresholdDepth(minDepth, minDepth + 200);
 
-            histogram = handImage.getHistogram();
+            histogram = handImage.getSmoothedHistogram();
             peakDepth = handImage.getPeakDepth();
         }
 
@@ -93,7 +93,7 @@ namespace bbiwarg.VideoHandles
             return peakDepth;
         }
 
-        public int[] getHistogram()
+        public int[] getSmoothedHistogram()
         {
             return histogram;
         }