Login  Register

Re: array in macro functions

Posted by Gabriel Landini on Feb 16, 2018; 10:06am
URL: http://imagej.273.s1.nabble.com/array-in-macro-functions-tp5020111p5020117.html

On Friday, 16 February 2018 09:31:50 GMT Csaba DÁVID wrote:
> Dear Jan,thank you for your advice. I was afraid that I have to learn
> another language. But it is probably not possible to learn Java in a week
> :( ThanksCsaba

You do not have to learn another language if you can do this as a macro:

You need to have stored the list of coordinates in some file or a text, so you
have one ROI per line.
Read the file somehow (there are macros showing how to do that in the
examples).
Then, make a loop:
Read one line of the text file (ROI) at a time,
Parse the number of coordinates in that line (there is a split function in the
macro language), and count them, e.g. 15.
Create the x and y arrays with that number of items  coorx=newArray(15), etc.
Assign the coordinates to the array (you can use another loop)
Call the makeSelection function as Herbie suggested
Plot the ROI
End of loop.

In the macro language you can generate an array again with a different number
of items at each iteration of the loop. You cannot do that in Java without
resorting to some tricks or using a List.

Hope it helps.

Gabriel

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html