|
@@ -19,12 +19,12 @@ namespace BBIWARG.Images
|
|
|
/// <summary>
|
|
|
/// the maximum depth which is considered important
|
|
|
/// </summary>
|
|
|
- public Int16 MaxDepth { get; private set; }
|
|
|
+ public UInt16 MaxDepth { get; private set; }
|
|
|
|
|
|
/// <summary>
|
|
|
/// the minimum depth in the raw depth image
|
|
|
/// </summary>
|
|
|
- public Int16 MinDepth { get; private set; }
|
|
|
+ public UInt16 MinDepth { get; private set; }
|
|
|
|
|
|
/// <summary>
|
|
|
/// image size of the depth image
|
|
@@ -38,20 +38,16 @@ namespace BBIWARG.Images
|
|
|
/// <param name="rawDepthData">the raw depth data</param>
|
|
|
/// <param name="size">the image size</param>
|
|
|
/// <param name="confidenceImage">the confidence image</param>
|
|
|
- public DepthImage(IntPtr rawDepthData, ImageSize size, ConfidenceImage confidenceImage)
|
|
|
+ public DepthImage(Image<Gray, UInt16> rawDepthImage)
|
|
|
{
|
|
|
- Size = size;
|
|
|
- Image<Gray, Int16> rawDepthImage = new Image<Gray, Int16>(Size.Width, Size.Height, Size.Width * 2, rawDepthData);
|
|
|
-
|
|
|
- // filter with confidenceImage mask
|
|
|
- rawDepthImage = rawDepthImage.Or((1 - confidenceImage.Mask).Convert<Gray, Int16>().Mul(Int16.MaxValue));
|
|
|
-
|
|
|
+ Size = new ImageSize(rawDepthImage.Width, rawDepthImage.Height);
|
|
|
+
|
|
|
// smooth with median filter
|
|
|
rawDepthImage = rawDepthImage.SmoothMedian(Parameters.DepthImageMedianSize);
|
|
|
|
|
|
// threshold min&maxDepth
|
|
|
MinDepth = findMinDepth(rawDepthImage);
|
|
|
- MaxDepth = (Int16)(MinDepth + Parameters.DepthImageDepthRange);
|
|
|
+ MaxDepth = (UInt16)(MinDepth + Parameters.DepthImageDepthRange);
|
|
|
|
|
|
// threshold (dst = (src > (MaxDepth - MinDepth)) ? MaxDepth - MinDepth : src)
|
|
|
Image = (rawDepthImage - MinDepth).ThresholdTrunc(new Gray(MaxDepth - MinDepth)).Convert<Gray, byte>();
|
|
@@ -65,7 +61,7 @@ namespace BBIWARG.Images
|
|
|
/// </summary>
|
|
|
/// <param name="point">the point</param>
|
|
|
/// <returns>depth at the point</returns>
|
|
|
- public Int16 getDepthAt(Point point)
|
|
|
+ public UInt16 getDepthAt(Point point)
|
|
|
{
|
|
|
return getDepthAt(point.X, point.Y);
|
|
|
}
|
|
@@ -76,15 +72,15 @@ namespace BBIWARG.Images
|
|
|
/// <param name="x">x coordinate of the position</param>
|
|
|
/// <param name="y">y coordinate of the position</param>
|
|
|
/// <returns>the depth at the position</returns>
|
|
|
- public Int16 getDepthAt(int x, int y)
|
|
|
+ public UInt16 getDepthAt(int x, int y)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- return (Int16)(MinDepth + Image.Data[y, x, 0]);
|
|
|
+ return (UInt16)(MinDepth + Image.Data[y, x, 0]);
|
|
|
}
|
|
|
catch (IndexOutOfRangeException e)
|
|
|
{
|
|
|
- return (Int16)(MinDepth + Image.Data[0, 0, 0]);
|
|
|
+ return (UInt16)(MinDepth + Image.Data[0, 0, 0]);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -96,18 +92,18 @@ namespace BBIWARG.Images
|
|
|
/// <param name="x">x coordinate of the position</param>
|
|
|
/// <param name="y">y coordinate of the position</param>
|
|
|
/// <returns>the depth at the position</returns>
|
|
|
- public Int16 getDepthAtFixed(int x0, int y0, int x1, int y1)
|
|
|
+ public UInt16 getDepthAtFixed(int x0, int y0, int x1, int y1)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
int rx = (int) ((x1 - x0) * 0.15f + x0);
|
|
|
int ry = (int) ((y1 - y0) * 0.15f + y0);
|
|
|
|
|
|
- return (Int16)(MinDepth + Image.Data[ry, rx, 0]);
|
|
|
+ return (UInt16)(MinDepth + Image.Data[ry, rx, 0]);
|
|
|
}
|
|
|
catch (IndexOutOfRangeException e)
|
|
|
{
|
|
|
- return (Int16)(MinDepth + Image.Data[0, 0, 0]);
|
|
|
+ return (UInt16)(MinDepth + Image.Data[0, 0, 0]);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -116,7 +112,7 @@ namespace BBIWARG.Images
|
|
|
/// </summary>
|
|
|
/// <param name="point">point where the depth is set</param>
|
|
|
/// <param name="depth">new depth value</param>
|
|
|
- public void setDepthAt(Point point, Int16 depth)
|
|
|
+ public void setDepthAt(Point point, UInt16 depth)
|
|
|
{
|
|
|
setDepthAt(point.X, point.Y, depth);
|
|
|
}
|
|
@@ -127,7 +123,7 @@ namespace BBIWARG.Images
|
|
|
/// <param name="x">x coordinate of position to set depth</param>
|
|
|
/// <param name="y">y coordinate of position to set depth</param>
|
|
|
/// <param name="depth">new depth value</param>
|
|
|
- public void setDepthAt(int x, int y, Int16 depth)
|
|
|
+ public void setDepthAt(int x, int y, UInt16 depth)
|
|
|
{
|
|
|
Image.Data[y, x, 0] = (byte)(depth - MinDepth);
|
|
|
}
|
|
@@ -137,7 +133,7 @@ namespace BBIWARG.Images
|
|
|
/// </summary>
|
|
|
/// <param name="image">the image</param>
|
|
|
/// <returns>the minimum depth</returns>
|
|
|
- private Int16 findMinDepth(Image<Gray, Int16> image)
|
|
|
+ private UInt16 findMinDepth(Image<Gray, UInt16> image)
|
|
|
{
|
|
|
// min and max values
|
|
|
double[] min, max;
|
|
@@ -147,7 +143,7 @@ namespace BBIWARG.Images
|
|
|
|
|
|
image.MinMax(out min, out max, out minLoc, out maxLoc);
|
|
|
|
|
|
- return (Int16)min[0];
|
|
|
+ return (UInt16)min[0];
|
|
|
}
|
|
|
}
|
|
|
}
|