浏览代码

Fixed thresholdBinary():

Daniel Kauth 11 年之前
父节点
当前提交
76977012aa
共有 2 个文件被更改,包括 14 次插入2 次删除
  1. 12 1
      bbiwarg/Images/DepthImage.cs
  2. 2 1
      bbiwarg/VideoHandle/VideoHandle.cs

+ 12 - 1
bbiwarg/Images/DepthImage.cs

@@ -73,7 +73,18 @@ namespace bbiwarg.Images
 
         public void thresholdBinary(Int16 thresholdDepth)
         {
-            image = image.ThresholdBinary(new Gray(thresholdDepth), new Gray(Int16.MaxValue));
+            Int16 maxDepth = getMaxDepth();
+            for (int x = 0; x < width; ++x)
+            {
+                for (int y = 0; y < height; ++y)
+                {
+                    Int16 depth = getDepth(x, y);
+                    if (depth <= thresholdDepth)
+                        setDepth(x, y, 0);
+                    else if (depth != maxDepth)
+                        setDepth(x, y, (short) (maxDepth / 2));
+                }
+            }
         }
 
         public int[] getSmoothedHistogram()

+ 2 - 1
bbiwarg/VideoHandle/VideoHandle.cs

@@ -81,8 +81,9 @@ namespace bbiwarg.VideoHandles
             colorImage = inputProvider.getColorImage();
 
             handImage.filterMedian(3);
-            int minDepth = handImage.getMinDepth();
+            Int16 minDepth = handImage.getMinDepth();
             handImage.thresholdDepth(minDepth, minDepth + 200);
+            handImage.thresholdBinary((short) (minDepth + 50));
 
             histogram = handImage.getSmoothedHistogram();
             peakDepth = handImage.getPeakDepth();