byte intensity = (byte)(depth >= minDepth && depth <= maxDepth ? depth : 0);
//WHAT IS THIS LINE ABOVE DOING?
The line above is using the Ternary Operator
Basically its a one line if statement and is equivalent to:
byte intensity;
if (depth >= minDepth && depth <= maxDepth)
{
intensity = (byte)depth;
}
else
{
intensity = 0;
}
The trick to colouring the depth image is to multiply the intensity by a tint colour. For example:
Color tint = Color.FromArgb(0, 255, 0) // Green
// Write out blue byte
this.colorPixels[colorPixelIndex++] = intensity * tint.B;
// Write out green byte
this.colorPixels[colorPixelIndex++] = intensity * tint.G;
// Write out red byte
this.colorPixels[colorPixelIndex++] = intensity * tint.R;