ImageJ Macro: Different types of arrays

Hi there,

First of all, is there a way in the FIji macro language to check what type a certain variable is, like you can do in Python? (x.type)

If not, can someone explain to me the differences between these two ways of creating an empty “Array”, for example for the purpose of populating it later in a for loop:

NewVar = ‘’ ';
NewVar2 = NewArray(size);

I understand my question is super vague, so if anyone can point me in the right direction in terms of what to read about this, I would be grateful.

1 Like

Hi @Isq,

first of all, ImageJ macro is compared to Python a quite limited language. It’s made for calling some ImageJ operations in a row, not for building complex software. If you plan to build something bigger with ImageJ, I’d recommend using Fijis Jython. There is a nice online tutorial by @albertcardona.

Regarding your questions: I’m not aware of any isType or typeOf method.
The newArray Method works like this:

emptyArray = newArray(0);
print("Empty array:")

arrayWithThreeElements = newArray(3);
print("Array with three empty elements:")

arrayWithFourElements = newArray(1,2,3,4);
print("Array with four elements:")

longArray = Array.concat(arrayWithThreeElements, arrayWithFourElements);
print("Array with seven elements:")


There is also some explanation of numeric variables, strings and arrays online:

Let us know if that helps!



@haesleinhuepf this Jython resource is absolutely amazing, I guess if I plan to do more complex macro development it’s worth learning it (I already know some Python so hopefully it shouldn’t take too long), I definitely feel the ImageJ macro is quite restricting.

Thanks again :wink:

1 Like