# Silhouette Kinect V2 + Removing Background

**URL:** <https://discourse.processing.org/t/silhouette-kinect-v2-removing-background/8472>\
**Category:** Libraries\
**Created:** [February 17, 2019, 10:43am UTC](https://discourse.processing.org/t/silhouette-kinect-v2-removing-background/8472 "2019-02-17T10:43:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrtnmur](https://avatars.discourse-cdn.com/v4/letter/m/e274bd/32.png) [@mrtnmur](https://discourse.processing.org/u/mrtnmur)\
**Post date:** [February 17, 2019, 10:43am UTC](https://discourse.processing.org/t/silhouette-kinect-v2-removing-background/8472/1 "2019-02-17T10:43:24Z")

</div>

Hello There,

And thank you for your amazing work. I’m a beginner in processing and I am trying to remove the background from the information captured through a kinectv2. I’ve made a Threshold selection of the depth information and would like to convert the pixels displayed in the image I attach that are now shown in black as an alpha channel. My idea is to end up using the body’s silhouette to draw your movement on the screen with a delayed effect. Liked in the following example: [https://www.youtube.com/watch?v=YBKkVpRxUfs](https://www.youtube.com/watch?v=YBKkVpRxUfs)  
I would really appreciate your help.

 ![20](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/5/5b07844021269fb42ce43d2c05152ea44a6f795b.png)

Here is the coding I have now:

```auto
import org.openkinect.freenect.*;
import org.openkinect.freenect2.*;
import org.openkinect.processing.*;
import org.openkinect.tests.*;

Kinect2 kinect2;

float minThresh = 480;
float maxThresh = 830;

PImage img;

void setup() {
  //size(1280, 720);
  fullScreen(FX2D);
  kinect2 = new Kinect2(this);
  kinect2.initDepth();
  kinect2.initDevice();
  img = createImage(kinect2.depthWidth, kinect2.depthHeight, RGB);
}

void draw() {
  background(255, 0, 0);

  img.loadPixels();
  int[] depth = kinect2.getRawDepth();

  for (int x = 0; x < kinect2.depthWidth; x++) {
    for (int y = 0; y < kinect2.depthHeight; y++) {
      int offset = x + y * kinect2.depthWidth;
      int d = depth[offset];
      if (d > minThresh && d < maxThresh) {
        img.pixels[offset] = color(255);
      } else {
        img.pixels[offset] = color(0, 0, 0, 0);
      }
    }
  }

  noStroke();
  img.updatePixels();
  image(img, 0, 0);
}

```

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [February 20, 2019, 7:45pm UTC](https://discourse.processing.org/t/silhouette-kinect-v2-removing-background/8472/2 "2019-02-20T19:45:34Z")

</div>

@mrtnmur – were you able to resolve this issue?

You might be interested in these past discussions of implementing a sketch similar to Recollections:

> [@Framerate in live video delay project : Ed Tannenbaum, Recollections](https://discourse.processing.org/t/framerate-in-live-video-delay-project-ed-tannenbaum-recollections/3129/28):
>
> You are still computing the int() operation and the modulus one for every pixel of the image. Again, I really don’t know if this can be it, I’m not qualified enough to be sure about the performance of those functions. Someone more capable can surely tell us if it can be that. Edit: You can try something like this. You create an array with 256 values let’s call it brightToCol. Since you have 8 different colors you would fill it in like this: brightToCol[0] = 0; brightToCol[1] = 1; ... brigh…

> [@Trails on a webcam image that detects motion](https://discourse.processing.org/t/trails-on-a-webcam-image-that-detects-motion/3313/2):
>
> Hi unknowplayer, I tried to run your code a code a really weird result (I was standing still so no motion at all): [WeirdResult] Also I’m not sure to get what you are trying to do but I think it is really close to the effect in this thread: [Framerate in live video delay project : Ed Tannenbaum, Recollections](https://discourse.processing.org/t/framerate-in-live-video-delay-project-ed-tannenbaum-recollections/3129/29) You might find some interesting informations here.
