Forums > Jitter

jit.expr issue

September 11, 2009 | 2:15 pm

Hi,

I am working with a a 2 plane char matrix and trying to convert pix to world range inside matrix land.

I can’t get results with this expr:
[jit.expr @expr "(in[0].p[0] / 320.)*2. -1." "(in[0].p[1] / 240.)*2. -1."]

any idea?

– Pasted Max Patch, click to expand. –

September 11, 2009 | 6:19 pm

not sure exactly what you are trying to do.
the char matrix is spitting out values between 0 and 255. if you want to convert that to float, between 0. and 1., simply convert the type of the matrix to float32:

jit.expr 2 float32 4 1 @adapt 0 @expr in[0] in[0]

looks like maybe you want 0 255 to -1 to 1:

jit.expr 2 float32 4 1 @adapt 0 @expr (in[0]*2)-1 (in[0]*2)-1

not sure why you have 320 and 240 so maybe you can explain more what you’re trying to achieve.


September 11, 2009 | 7:31 pm

Sorry, there was an error in my statement.
Yes, of course a char matrix goes up to 255.

I was trying to convert float32 matrix filled with values between 0-320. for plane 0 and 0-240 for plane 1 to world coordinates.
That is good now.

However I’d like now to tell my expr to convert plane 1 from 0. 240. to 1. -1. not -1. 1.

My patch allows to sort elmts from cv.jit.sort and fill a new matrix without "cell-jump".

I tryed
(-in[0].p[1] / 240.)*2. -1.
(in[0].p[1] / -240.)*2. -1.

But don’t really know how to do this ..

Thank you.

– Pasted Max Patch, click to expand. –

September 11, 2009 | 7:45 pm

(((in[0].p[1]/240.)*2.)-1.)*-1.


September 11, 2009 | 8:01 pm

Yes, Thanks.

But is there a reason for [jit.expr] does’nt accept the "" in my second expression?

– Pasted Max Patch, click to expand. –

January 6, 2010 | 10:08 am

Yes, thanks ej.

Other, I discovered that exprfill message to [jit.matrix] do not work as expr message do with [jit.expr].
I thought that they both would work the same way? But no?

It would be nice to have clarifications with expression syntaxe and features.
A special tutorial somewhere would be nice.

– Pasted Max Patch, click to expand. –

January 6, 2010 | 5:38 pm

Writing an in-depth jit.expr/exprfill tutorial has been on my "Todo Someday" list for some time now. Some of the later Jitter Recipes in Book 3 make use of it to draw geometry.

For your particular problem, exprfill can’t understand the "in[0]" because, well the exprfill is a one time action on a jit.matrix. If you need a dynamic expression with inputs, you are better off using jit.expr.

Also, if you want to fill different planes with different expressions, you need to use separate exprfill messages with a plane argument before the expression, i.e. (exprfill 0 snorm[0],exprfill 1 snorm[1]).

Andrew B.



efe
January 6, 2010 | 8:15 pm

indeed, it would be fantastic to have a jit.expr tutorial as it is one of the most powerful objects within jitter. Please keep us informed if it happens!


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