Login  Register

Re: x y coords of anchor points on segmented line

Posted by Volker Baecker on Apr 02, 2015; 1:04pm
URL: http://imagej.273.s1.nabble.com/x-y-coords-of-anchor-points-on-segmented-line-tp5012312p5012325.html

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

It's really not as complicated as it looks.

for(i=0; i<xx.length; i++) {
        result += "" + xx[i] + " " + (height - yy[i]);
        if (i<xx.length - 1) result += ", ";
}

In the for-loop the index i will run from 0 to length of the array xx
minus one. In each iteration the two coordinate values x and y are
added to the result string. The value of y is inverted by subtracting
it from the height of the image.
In each iteration except the last a comma is added to the result string.

Note that "result +="  is short for "result = result  + "

<shameless self-advertisement>

If you want to know more about ImageJ macro programming you can have a
look at my workshop at:

http://dev.mri.cnrs.fr/projects/imagej-macros/wiki/ImageJ_Macro_Programming_for_Biological_Image_Analysis

</shameless self-advertisement>

Volker
Tobias Baskin:
> Volker, Perfect! Wow! I cannot even pretend to understand the
> syntax of that do loop. But it certainly works. This will save me a
> bunch of time (I have been writing down those points by hand!). I
> am tremendously grateful.
>
> As ever, Tobias
>
> -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

-----BEGIN PGP SIGNATURE-----

iQEcBAEBCgAGBQJVHT5zAAoJENcVU956o58N/e8H/1j07U9AltCcBq8XS6BvdZFy
aFL27MnVHFAln+qfgQTCM6tlpHXz/hfcg24/D4GspnZWyui8zjd9emDP3ORRsrW1
KbhO77qA7Yq49IYmPk2RSV8scTV5PHmcPvn35fGj9f8T0dbiieMfUZfdjMnu3eiP
aHQTyVqzBsHaR9KkB/nxFHye8AT3ifeOdAqd8I138Nc5f5Cu1PZ1BJrHyZ+CAh8R
Nk1PuBjDzrpGsJaMSByHOYZ2WZN1JdkiuIsFbMmqp/qd3pQEbRGewZlUyS014QAa
XnFp41jDYWGBvugHJsN0zcdKbjcvihzw++wSovjhNXp+UEQqCr4JxOArPB58fMA=
=KSeC
-----END PGP SIGNATURE-----

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