Search code examples
arraysmacrosimagej

Filling array with values in ImageJ macro


I have a 2D array that I would like to fill with numbers, one row at a time. For example, if my array was n x m in size, I would write loop m times to fill each row with n values. How do I do I write this for an ImageJ macro? I would normally write something like:

n=10;
m=5;
array=newArray(n,m);
FOR (i=0;i<m;i+=1){
numbers=newArray(m);
array[*,i]=numbers;
}

However, array[*,i] obviously does not work, nor does array[j][i] if I add another loop 'j' within loop 'i'. Could someone please help? I am very new to writing macros in ImageJ. Thanks.


Solution

  • According to Wayne Rasband(developer of ImageJ) the macro language does not support two dimensional arrays.

    I would suggest you consider writing a plugin in Java. There is a good guide here here that also compares macros and plugins. The more complicated the image processing the more you should think about using Java.

    Other options include using Fiji's python interface.