Browse Source

segmentationDepth now searches min between peaks

Alexander Hendrich 11 years ago
parent
commit
45098c8cf8
3 changed files with 22 additions and 7 deletions
  1. 3 3
      bbiwarg/Graphics/Output2D.cs
  2. 17 3
      bbiwarg/Images/DepthImage.cs
  3. 2 1
      bbiwarg/VideoHandle/VideoHandle.cs

+ 3 - 3
bbiwarg/Graphics/Output2D.cs

@@ -97,9 +97,9 @@ namespace bbiwarg.Graphics
             GL.LineWidth(5.0f);
             for (int i = 0; i < histogram.Length; ++i)
             {
-                if (i > segmentationDepth[0] - minDepth) GL.Color3(Color.Yellow);
-                if (i > segmentationDepth[1] - minDepth) GL.Color3(Color.Red);
-                if (i > segmentationDepth[2] - minDepth) GL.Color3(Color.Silver);
+                if (i > segmentationDepth[0]) GL.Color3(Color.Yellow);
+                if (i > segmentationDepth[1]) GL.Color3(Color.Red);
+                if (i > segmentationDepth[2]) GL.Color3(Color.Silver);
                 
                 GL.Vertex3(-0.25 + i * (0.5 / histogram.Length), -0.25 + histogram[i] * (0.5 / (maxValue - 5)), -0.5);
             }

+ 17 - 3
bbiwarg/Images/DepthImage.cs

@@ -138,12 +138,26 @@ namespace bbiwarg.Images
                 }
             }
 
+            if (secondMaxIndex < firstMaxIndex) {
+                Int16 dummy = firstMaxIndex;
+                firstMaxIndex = secondMaxIndex;
+                secondMaxIndex = dummy;
+            }
+
+            // get min in between
+            Int16 minIndex = firstMaxIndex;
+            for (Int16 i = firstMaxIndex; i < secondMaxIndex; i++) {
+                if (histogram[i] < histogram[minIndex]) {
+                    minIndex = i;
+                }
+            }
+
             Int16 minDepth = getMinDepth();
 
             Int16[] result = new Int16[3];
-            result[0] = (Int16) (Math.Min(firstMaxIndex, secondMaxIndex) + minDepth);
-            result[1] = (Int16) ((firstMaxIndex + secondMaxIndex) / 2 + minDepth);
-            result[2] = (Int16) (Math.Max(firstMaxIndex, secondMaxIndex) + minDepth);
+            result[0] = firstMaxIndex;
+            result[1] = minIndex;
+            result[2] = secondMaxIndex;
 
             return result;
         }

+ 2 - 1
bbiwarg/VideoHandle/VideoHandle.cs

@@ -83,10 +83,11 @@ namespace bbiwarg.VideoHandles
             handImage.filterMedian(3);
             Int16 minDepth = handImage.getMinDepth();
             handImage.thresholdDepth(minDepth, minDepth + 200);
-            handImage.thresholdBinary((short) (minDepth + 50));
 
             histogram = handImage.getSmoothedHistogram();
             segmentationDepth = handImage.getSegmentationDepth();
+
+            handImage.thresholdBinary((Int16) (segmentationDepth[1]+minDepth));
         }
 
         public Int16[] getSegementationDepth()