Forums > Jitter

Reporting the second lowest value in a matrix

Jun 18 2013 | 10:20 am

I have been playing with jit.openni and would like to report how far away an object is from the kinect. To do this I will need to report on the lowest value in the 1 plane depth map output. My question then is how do I report the second lowest value within a matrix so that I can ignore black areas?

Any help would be appreciated! :)

Jun 19 2013 | 2:02 am

I’ve tried using jit.spill to output a list, hoping that I could run zl on it and extract the second lowest value. While this would work in theory, outputting the medium sized matrix (100×100) as a list was too much of a drain on my system. I’ve also looked at jit.3m which can tell me the minimum value of the matrix but not he second lowest value. Am I looking in the right places, or are their any obvious objects I should be looking at?

Jun 19 2013 | 4:09 am

if you use jit.3m and get the lowest value, you can process that value out of your matrix, leaving you with second-lowest and above, right?

Jun 19 2013 | 4:55 am

Thanks for the reply Wetterberg. Your logic seems spot on to me, but I’m unsure how to do that, sadly my experience with Jitter is not comparable to my experience with Max! I know that my minimum will always be 0 within the Kinect depth map feed I am using, so how best to process out 0’s from my matrix?

Jun 19 2013 | 5:13 am

You could make it something really large like 999999 with a jit.expr, before running it into jit.3m:

jit.expr @expr ((in[0]==0.)*999999.)+((in[0]!=0.)*in[0])

This equals to: if $f1 == 0 then 999999 else $f1

(My jit.expr ‘s a bit rusty so hope that’s correct…)

Jun 19 2013 | 7:12 am

Horrah! That’s nailed it! Thanks guys.

Viewing 6 posts - 1 through 6 (of 6 total)

Forums > Jitter