public void ConverToGrayScale(byte[] pixelData) { var mapper = new CoordinateMapper(sensor); var depthPoints = new DepthImagePoint[640 * 480]; // map depth and pixel data mapper.MapColorFrameToDepthFrame( ColorImageFormat.RgbResolution640x480Fps30, DepthImageFormat.Resolution640x480Fps30, depthImagePixels, depthPoints); for (int i = 0; i < depthPoints.Length; i++) { var pixelDataIndex = i * 4; var point = depthPoints[i]; // if pointer is further than 800 mm and is not recognized as a valid point if (point.Depth > 800 || KinectSensor.IsKnownPoint(point) == false) { var max = Math.Max(pixelData[pixelDataIndex], Math.Max(pixelData[pixelDataIndex + 1], pixelData[pixelDataIndex + 2])); // use maximum value to set r g b values. pixelData[pixelDataIndex] = max; //blue pixelData[pixelDataIndex + 1] = max; //green pixelData[pixelDataIndex + 2] = max; //red } } }
private void GrayscaleData(byte[] pixelData) { var mapper = new CoordinateMapper(sensor); var depthPoints = new DepthImagePoint[640 * 480]; mapper.MapColorFrameToDepthFrame(ColorImageFormat.InfraredResolution640x480Fps30, DepthImageFormat.Resolution640x480Fps30, depthImagePixels, depthPoints); for (int i = 0; i < depthPoints.Length; i++) { var point = depthPoints[i]; if (point.Depth > 600 || !KinectSensor.IsKnownPoint(point)) { var pixelDataIndex = i * 4; var max = Math.Max(pixelData[pixelDataIndex], Math.Max(pixelData[pixelDataIndex + 1], pixelData[pixelDataIndex + 2])); pixelData[pixelDataIndex] = max; pixelData[pixelDataIndex + 1] = max; pixelData[pixelDataIndex + 2] = max; } } }
private void GrayscaleData(byte[] pixelData) { // Mapping depth to color var mapper = new CoordinateMapper(sensor); var depthPoints = new DepthImagePoint[640 * 480]; mapper.MapColorFrameToDepthFrame(ColorImageFormat.RgbResolution640x480Fps30, DepthImageFormat.Resolution640x480Fps30, depthImagePixels, depthPoints); for (int i = 0; i < depthPoints.Length; i++) { var point = depthPoints[i]; if (point.Depth > 600 || KinectSensor.IsKnownPoint(point)) { var pixelDataIndex = i * 4; var maxValue = Math.Max(pixelData[pixelDataIndex], Math.Max(pixelData[pixelDataIndex + 1], pixelData[pixelDataIndex + 2])); pixelData[pixelDataIndex] = maxValue; pixelData[pixelDataIndex + 1] = maxValue; pixelData[pixelDataIndex + 2] = maxValue; } } }