Re: import xy coordinates

Posted by dscho on
URL: http://imagej.273.s1.nabble.com/import-xy-coordinates-tp3682787p3682788.html

Hi Philippe,

On Mon, 24 Oct 2011, Pouletaut wrote:

> is there a way to import a xy coordinates file in order to plot and
> overlay a contour on a image ? The file consists of two columns of float
> coordinates in ASCII format, gathering ordered points of a contour.

The easiest method would probably to write a macro. It would use the
following functions:

- File.openAsString() (or File.openAsRawString() if the file is larger
  than 5000 bytes) to read in the contents

- split() to separate the lines

- newArray() to make one array for the x and one for the y coordinates

- a loop iterating over all the lines

- inside the loop another split() to separate the numbers

- parseFloat() to convert the textual representation of the numbers into
  numeric values

- after the loop, makeSelection() to turn the arrays into a ROI

- run() to call the "Add selection..." plugin to add the ROI to the overlay

Ciao,
Johannes