Two Dimensional Arrays

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Two Dimensional Arrays

David Sykes-2
I have a text file containing 2,408,448 ascii floating-point values separated by spaces.
These represent height values of my local area (North Wales) arranged as 1344 rows wach containing 1792 columns.
I am trying to read these into a two-dimensional array that can then be easily 'cutup' into smaller tiles, at the
smallest level 1024 tiles 56x42 in size.

ImageJ accepted the following JavaScript statements :-

var DEM = newArray(numColumns);  // DEM = 'digital elevation model'
for(i=0;i<numColumns;i++)
{
DEM[i] = newArray(numColumns);   // this should create a 2D array
}

Attempts to fill the array so created (if it was) with this failed :-

DEM[row][column] =  some value.


Is there an alternative way of doing this ?


David Sykes
Wales, UK
Reply | Threaded
Open this post in threaded view
|

Re: Two Dimensional Arrays

Wayne Rasband
> I have a text file containing 2,408,448 ascii floating-point values
> separated by spaces. These represent height values of my local area
> (North Wales) arranged as 1344 rows wach containing 1792 columns.
> I am trying to read these into a two-dimensional array that can then
> be easily 'cutup' into smaller tiles, at the smallest level 1024
> tiles 56x42 in size.
> ImageJ accepted the following JavaScript statements :-
>
> var DEM = newArray(numColumns);  // DEM = 'digital elevation model'
> for(i=0;i<numColumns;i++)
> {
> DEM[i] = newArray(numColumns);   // this should create a 2D array
> }
>
> Attempts to fill the array so created (if it was) with this failed :-
>
> DEM[row][column] =  some value.
The ImageJ macro language does not support 2D arrays.
> Is there an alternative way of doing this ?
Open the text file as an image using File>Import>Text Image. Use the  
command recorder to generate macro code that does this. The text file  
will need to have a linefeed character at the end of each line.

-wayne