Generating lists of number

macro
Tags: #<Tag:0x00007fd53e7d5148>

#1

Hi, sorry if this is a basic question! When I’m writing a macro, I can’t for the life of me work out how to get a list of numbers from X to Y by Z. For instance in R I would do:

1 : 10

Returning:

[1] 1 2 3 4 5 6 7 8 9 10

Or I would do:

seq(0, 10, 2)

Returning:

[1] 0 2 4 6 8 10

Or in python I would use range(0, 10)

How is this done in an ImageJ macro?


#2

Hava a look at the Array function:

https://imagej.nih.gov/ij/developer/macro/functions.html

Example:

https://imagej.nih.gov/ij/macros/examples/ArrayFunctions.txt

For example:

x=Array.getSequence(10)

for ( i=0 ; i < x.length; i++) {
print(x[i]);

}

Of course you won’t get all functions avaiable in R and Python but you can easily create them yourself or by using
external Java libs.