Here is another tip on Kinect for Windows SDK Tips series. The color camera of Kinect device delivers the color stream data with the combination of three basic color components red, green and blue (RGB). This stream data is nothing but a succession of still image frame that consist of the color pixel. You can take control over the each and individual color frame pixels and apply a color filter on the basic color components.
Each RGB pixel of the color image frame is an array of size four. The first three values represent the values of blue, green, and red, whereas the fourth value is the alpha value for that pixel.
The maximum value of each color is 255 and the minimum is 0. The following screenshot shows the color values for blue, green, and red along with the alpha values from an image frame that has been captured using Kinect color camera.
To apply the color effects, or filter on specific color, You can easily iterate through the array and set the value. The following code block refers to how you can apply only red color effects on an image stream by just filtering on green and blue (setting 0 for green and blue pixel).
for (int i = 0; i < this.pixelData.Length; i += imageFrame. BytesPerPixel) { this.pixelData[i] = 0; //Blue this.pixelData[i + 1] = 0; //Green }
Must Read : Kinect for Windows SDK Tips
As every pixel is represented by an array of length four, which is nothing but imageFrame.BitsPerPixel , we are increasing the loop with the same number. Similar to changing the red value, you can set the values for green and blue; you can even give a combination of these three values to apply some more color effects on the images.
Note that, processing on the pixel level can degrade the application performance.
And, don’t forgot to check out the Kinect for Windows SDK Tips