1

I was wondering if it is possible in opencv to have a threshold value per pixel. For example p(x,y) should be above 100 and then p(x+1,y) should be above 101.

You can see this as background subtraction. So that everything in front of the background remains.

I was thinking something like this. I have an image and then the other image. I subtract them. This means everything that is left should be above the threshold.

For example:

enter image description here

At the right side is the image taken when the camera (kinect) is launched. Then the image to the left is the current camera feed - the image at the left side.

the code :

cvSub(depth, depthInit, difference, null);

Since nothing changes this should be more black (I can understand there is some noise)

Could this be because there are negative values left or something ?

Thx in advance

Jav_Rock
  • 22,059
  • 20
  • 123
  • 164
Olivier_s_j
  • 5,490
  • 24
  • 80
  • 126

2 Answers2

0

Take a look at this question. It helps you?

You can also try to sweep pixel per pixel, using a for, and increment the thresholds...

Community
  • 1
  • 1
cyberdecker
  • 574
  • 12
  • 24
0

I think you want cvCmp (Docs)

// make sure threshold is zero to start with
cvZero(thresholded);
// for pixels where current > background, sets thresholded = high value
cvCmp(current, background, thresholded, CV_CMP_GT);
dantswain
  • 5,427
  • 1
  • 29
  • 37
  • I suppose this does the trick, though i can't completely confirm since my results consist of a lot of noise due to the Kinect. – Olivier_s_j Mar 19 '12 at 18:03
  • Just stick something in there :) cvSub *should* truncate negative values to 0 (it does in C). You can get the same effect by doing cvAbsDiff, cvCmp, and then cvAnd the results. – dantswain Mar 19 '12 at 18:26