ajayk0719 / jai-tools

Automatically exported from code.google.com/p/jai-tools
0 stars 0 forks source link

Jiffle: neighbourhood syntax #23

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
At the moment jiffle uses square bracket notation to index pixel positions 
relative to the current 
runtime position. 

Example: myImage[ -1, 1 ] accesses the value at x-1:y+1 where x and y are the 
current position.

I want to modify this syntax to support both relative and absolute image 
positions and also 
mutli-band images (source and destination).

Examples of the proposed new syntax:

Relative image position (band 0 implied)
myImage[ xoff, yoff ]@rel

Absolute image position (band 0 implied)
myImage[ x, y ]@abs

No trailing annotation means absolute (change to existing behaviour)...
myImage[ x, y ]

Absolute position with a specified band...
myImage[ x, y, band ] or myImage[ x, y, band ]@abs

Relative position with a specified band (note band index is absolute, not 
relative)...
myImage[ xoff, yoff, band ]@rel

Original issue reported on code.google.com by michael.bedward@gmail.com on 5 Jan 2010 at 6:41

GoogleCodeExporter commented 9 years ago
Note, the square bracket notation is a jiffle extension over the GRASS 
r.mapcalc language so there shouldn't be 
any implications for running r.mapcalc scripts.  However, using unannotated 
square brackets to mean absolute 
rather than relative position will break existing scripts with neighbourhood 
calculations. Despite this, I think it's 
more intuitive and less error-prone to have it that way.

Original comment by michael.bedward@gmail.com on 5 Jan 2010 at 6:45

GoogleCodeExporter commented 9 years ago

Original comment by michael.bedward@gmail.com on 16 Apr 2010 at 12:08

GoogleCodeExporter commented 9 years ago
Hey Michael,
what about using the common spreadsheet notation to discern between relative 
and absolute?
In spreadsheets you have something like D3, which is absolute, but when you 
copy that formula to the cell below it, it will reference D4 instead: during 
the copy it's treated like a relative position.
That happens unless you prefix the row or column with $, for example, if you 
have $D$3 then wherever you copy the formula that cell reference won't change.

In Jiffle terms, $x, $y would be absolute references, while x, y would be 
relative.
This would also keep the syntax backwards compatible.

Original comment by andrea.a...@gmail.com on 20 Jan 2011 at 3:32

GoogleCodeExporter commented 9 years ago
Nice idea Andrea, although I have a severe allergy to Excel. I suppose I could 
try to get over it. 

Let's go with it.

I'm moving multi-band support into a new issue (editing subject of this one 
accordingly).

Original comment by michael.bedward@gmail.com on 21 Jan 2011 at 1:01

GoogleCodeExporter commented 9 years ago
Dollar prefix is working now. Thanks for the idea Andrea.

Committed to trunk r1315

Original comment by michael.bedward@gmail.com on 22 Jan 2011 at 12:46