wachub / jaitools

Automatically exported from code.google.com/p/jaitools
0 stars 0 forks source link

Jiffle: enable list operations in scripts #111

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Jiffle has a number of stats functions such as mean, median, sdev, but they are 
pretty useless because there's no easy way at the moment of collecting values 
from an image to pass to the function (unless the number of values is small and 
you use a script variable for each value).  It would be handy to support list 
operations in scripts.

Jiffle already has a list syntax used with one of the forms of foreach loops...

foreach ( z in { 1, 2, foo, bar } )

So it would be relatively easy to allow curly-bracket lists to be used in other 
contexts.

Original issue reported on code.google.com by michael.bedward@gmail.com on 15 Jun 2011 at 12:34

GoogleCodeExporter commented 9 years ago
Added list syntax to Jiffle grammar. Unit tests for assigning empty or 
initialized list to user var.

Original comment by michael.bedward@gmail.com on 15 Jun 2011 at 12:34

GoogleCodeExporter commented 9 years ago
Now have some unit tests where a list var is created with initial values and 
then passed to a stats function. Example:
    options { outside = 0; }
    z = [ src[0,-1], src, src[0,1] ];
    dest = max(z);

Next we want a way of adding values to an existing list. I don't want to use 
class.member syntax. Could steal the "<<" operator from Ruby...

foo = [];
foo << src;  // appends value of src to list foo

Could also steal the c (concatenate) function from R...
foo = c(foo, src);  

Though perhaps it would be better to call it "concat"...
foo = concat(foo, src);  // appends value of src to list foo
foo = concat(src, foo);  // prepends value of src to list foo

Both concat and "<<" seem good to have, the latter being nicely concise. 
Example, 3x3 mean filter with Jiffle...

options { outside = null; }
values = [];
for ( dy in -1:1 ) {
    for ( dx in -1:1 ) {
        values << src[ dy, dx ];
    }
}
dest = sum( values ) / 9;

Original comment by michael.bedward@gmail.com on 15 Jun 2011 at 12:34

GoogleCodeExporter commented 9 years ago
Append operator "<<" working.  Unit test in jaitools.jiffle.runtime.ListTest, 
method appendWithOperator

On trunk (r1472)

Original comment by michael.bedward@gmail.com on 15 Jun 2011 at 12:34

GoogleCodeExporter commented 9 years ago
The "concat" function is working in unit tests. See 
aitools.jiffle.runtime.ListTest

On trunk (r1473)

Original comment by michael.bedward@gmail.com on 15 Jun 2011 at 12:34

GoogleCodeExporter commented 9 years ago
Basic lists are working well enough for pixel neighbourhood operations. Later 
we can add element indexing etc.

Closing this issue.

Original comment by michael.bedward@gmail.com on 15 Jun 2011 at 12:34